0
\$\begingroup\$

How can I load an asset (model, texture, etc.) from a .zip file in Python's Ursina module without extracting it?

I tested this code:

from ursina import *
app = Ursina()
x = Entity(model="cube", texture="assets.zip/texture.png")
p = EditorCamera()
app.run()

But with no success (warning in the command prompt + entity appears white):

warning: missing texture: 'assets.zip/texture.png'

My file/folder structure is like this:

<root>/
  test.py
  assets.zip/
    texture.png
\$\endgroup\$
4
  • \$\begingroup\$ I didn't see anything in the documentation that suggests that you can use the syntax indicated in your question. If you have a tutorial /info that says you should be able to load a zipped texture into an Entity, please edit to include that reference. Otherwise, I would try loading the texture into a file-like object via code as shown here. \$\endgroup\$
    – Pikalek
    Aug 9 at 16:17
  • \$\begingroup\$ This did not solve my problem. The warning is gone, but the cube is still white. Both the texture file and the zip file are valid and the texture is not white. I also tried some other answers from that question, but all without success :( \$\endgroup\$ Aug 9 at 17:00
  • \$\begingroup\$ Just to verify some basics: are you able to successfully texture the model if you manually unzip the texture into the file system & use that with the constructor? \$\endgroup\$
    – Pikalek
    Aug 9 at 19:49
  • \$\begingroup\$ Unzipping the texture and using that works fine. \$\endgroup\$ Aug 10 at 15:26

0

You must log in to answer this question.

Browse other questions tagged .