[英]“load_texture” feature not existing in Ursina Engine
I recently started to use Ursina Engine (Python) but when i try to load a texture via 'load_texture()' command, it doesn't work.我最近开始使用 Ursina 引擎 (Python),但是当我尝试通过“load_texture()”命令加载纹理时,它不起作用。 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
...如果要使用纹理导入器,则需要导入
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...如果要使用自定义纹理 map,则不需要纹理导入,只需执行...
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) (当然,
my_image.png
是您的纹理,您可以将my image
部分更改为图像的任何名称)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.