I'm developing a game in Ursina. Since my old question did not get any answers, I decided to extract the zip file to a temporary directory and read the assets from there, but not everything runs well.
Part of the code:
sc = 25
with tempfile.TemporaryDirectory() as tempdir:
print(tempdir)
zf = zipfile.ZipFile("Game_Data")
zf.extractall(tempdir)
zf.close()
print(os.listdir(tempdir))
log("Creating scene", gt(time.time())) # logs to game.log file, log() and gt() definitions are not shown because they are irrelevant here.
t = Entity(model=load_model(tempdir+"\\Terrain.obj"),texture=tempdir+"\\Grass.jpg",collider="mesh")
t.texture.filtering = "mipmap"
s = Entity(model="sphere", double_sided=True, texture=tempdir+"\\Skybox.png", scale=10000*sc)
When I run the game, I get the error:
C:\Users\x\Desktop\Game>game.py
package_folder: C:\Users\x\AppData\Local\Programs\Python\Python311\Lib\site-packages\ursina
asset_folder: C:\Users\x\Desktop\Game
:prc(warning): Invalid integer value for ConfigVariable win-size: 819.2000122070312
:prc(warning): Invalid integer value for ConfigVariable win-size: 1024.0
Known pipe types:
wglGraphicsPipe
(3 aux display modules not yet loaded.)
:prc(warning): changing default value for ConfigVariable paste-emit-keystrokes from '1' to '0'.
1.0
:pnmimage:png(warning): iCCP: known incorrect sRGB profile
C:\Users\x\AppData\Local\Temp\tmpt8l3bk9w
['Grass.jpg', 'Skybox.png', 'Terrain.mtl', 'Terrain.obj']
warning: missing texture: 'C:\Users\x\AppData\Local\Temp\tmpt8l3bk9w\Grass.jpg'
Traceback (most recent call last):
File "C:\Users\x\Desktop\Game\Game.py", line 90, in <module>
t.texture.filtering = "mipmap"
^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'filtering'
C:\Users\x\Desktop\Game>
It seems like Terrain.obj
is loaded successfully (no error), but Grass.jpg results in None
, altough all the required assets are in the zip file Game_Data
(no file extension because the end user should not know it's actually a zip). Why?