Hi all,
I’m really stuck with this. I want my game to load images dynamically. I need this because I have an XML where I describe the spaceships. A spaceship has also an image. So when I show the spaceships during the game I load the images dynamically.
So I made a class to load images and I can create a Sprite with the loaded image. Everything worked fine until I checked the app on Android, because on the device I can’t open file normally but I need to use the WWW class because the correct path is of type: jar:file://
The problem is that WWW is asynchronous so I can’t find a way to have my “ImageLoader” class to return the Sprite once the WWW has completed to load the image.
I don’t want to use the Resources folder, if I’m not wrong, that would be terrible for performances.
How Unity developers handle this issue? Please help me I’m 1 day still from crazyness
Diego
You are wrong Loading from Resources is going to be the most straightforward way to achieve what you want.
I thought I was wrong because the Unity documentation says:
Don’t use it.
and also:
-
Use of the Resources folder makes fine-grained memory management more difficult.
-
Improper use of Resources folders will increase application startup time and the length of builds.
-
As the number of Resources folders increases, management of the Assets within those folders becomes very difficult.
-
The Resources system degrades a project’s ability to deliver custom content to specific platforms and eliminates the possibility of incremental content upgrades.
-
AssetBundle Variants are Unity’s primary tool for adjusting content on a per-device basis.
But I see my case is like the example at paragrapg 2.2 “Proper uses of the Resources system”
Yeah - whoever wrote that piece of documentation should be slapped Not because the information in it is technically wrong but it’s poorly written (as evidenced by the fact that it scared you away from a correct solution).
1 Like