![](/img/trans.png)
[英]How do I resolve if the texture does not load on the Ursina Engine? (load_texture does not work)
[英]“load_texture” feature not existing in Ursina Engine
我最近开始使用 Ursina 引擎 (Python),但是当我尝试通过“load_texture()”命令加载纹理时,它不起作用。 这就是它所说的。
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
有什么帮助吗?
遇到了完全相同的问题,仍然不知道如何解决它,但设法找到解决方法。 而不是例如:
x = load_texture('x.png')
[...]
texture = x
我马上做了:
texture = ('x.png')
编辑
跑过
app=Ursina()
在导入/加载纹理之前
如果要使用纹理导入器,则需要导入Ursina
的另一部分...
from ursina.texture_importer import load_texture
这允许您使用纹理导入器。
如果要使用自定义纹理 map,则不需要纹理导入,只需执行...
from ursina import *
app = Ursina()
model = Entity(model='cube', texture='my_image.png')
app.run()
(当然, my_image.png
是您的纹理,您可以将my image
部分更改为图像的任何名称)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.