![](/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.