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:

    zf = zipfile.ZipFile("Game_Data")


    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:

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:
(3 aux display modules not yet loaded.)
:prc(warning): changing default value for ConfigVariable paste-emit-keystrokes from '1' to '0'.
:pnmimage:png(warning): iCCP: known incorrect sRGB profile
['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'


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?

  • 1
    \$\begingroup\$ security through obscurity is not really that much helpful and even less if it is a zip file (which would be one of the first things a person who actually tries to use when they decide to try to open/ parse the game data). And how do you know that Terrain.obj is loaded correctly? You got the error on gras when you tried to access it in the next line. Not when you tried to load it \$\endgroup\$
    – Zibelas
    Aug 17 at 13:22


You must log in to answer this question.

Browse other questions tagged .