In my project, at the end of each level I am loading some prefabs and changing their sprites. Prefabs are in “Resources” folder so I access them by using Resources.Load method. Everything works fine when I run the game in Unity but when I build the project as .apk, it doesn’t load prefabs and change sprites. I made a lot of research but I couldn’t find an answer. There are no restrictions on Resources in a build project so what is the problem?
I’m having the exact same problem, I instantiate some prefabs and change their sprites, I’m loading the images from .png files in Resources ( using (Sprite)Resources.Load(“my_file”); )
It works perfectly fine on the unity editor, but not on my android device.
Edit: I seem to see where the problem lies, all my sprites are preloaded in a dictionary<string,Sprite> and for some reasons using the sprites from this dictionnary doesn’t work (well it works on the unity editor, but not the android device).
If I don’t preload them in the dictionary and reload the sprite everytime using (Sprite)Resources.Load(“my_file”); it works on both unity and android.
Edit2: I found the problem, I used System.IO.File.ReadAllText(“my_file”) to read from a .txt file instead of TextAsset data= Resources.Load(“My_file”) as TextAsset;
string text=data.text;
the first one doesn’t work with android but does work with the unity editor.
Thanks for updating your post with your findings, Biurk! That’s really helpful - not enough people do that.
berkc: I’d love to help, could you start by telling us what version of Unity you’re using and if you’re using System.IO like Biurk is? Their solution might work for you as well.