I recently started to use Ursina Engine (Python) but when i try to load a texture via 'load_texture()' command, it doesn't work. Here's what it says.
ursina version: 3.5.0 package_folder: C:\Users\minec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ursina asset_folder: D:\Voxel blender_paths: {'default': WindowsPath('D:/Blender/blender.exe')} screen resolution: (1920, 1080) Traceback (most recent call last): File "D:\Voxel\voxel.py", line 4, in <module> texture = load_texture('assets/texture/cobblestone.png') File "C:\Users\minec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ursina\texture_importer.py", line 40, in load_texture t = Texture(filename.resolve()) File "C:\Users\minec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ursina\texture.py", line 23, in __init__ self._texture = loader.loadTexture(Filename.fromOsSpecific(str(value))) NameError: name 'loader' is not defined
Any help?
Had exactly the same problem, don't know still how to fix it but managed to find a way around it. Instead of going for example:
x = load_texture('x.png')
[...]
texture = x
I did right away:
texture = ('x.png')
EDIT
Run the
app=Ursina()
prior to importing/loading the textures
If you want to use the texture importer, you need to import another part of Ursina
...
from ursina.texture_importer import load_texture
This allows you to use the texture importer.
If you want to use a custom texture map, you don't need to texture import, but simply do...
from ursina import *
app = Ursina()
model = Entity(model='cube', texture='my_image.png')
app.run()
(where, of course, my_image.png
is your texture, you can change the my image
part to any name of an image)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.