- Home /
Texture in the Unity Resouces path doesn't load on Android
I'm developing a game for Android using Unity, and I need load some texture from the Resources path. But this only works in the editor, and when I build the project for Android, the image doesn't load.
My code looks like this:
public void setTipTextTexture(string texture){
texture = "TipTexts/" + texture;
this.tipTexture = Resources.Load(texture) as Texture;
}
What am I doing wrong?
Hi,
I have the same problem. In unity can see the sprites but i cant see it in android.
The resource load line are these:
public static string rutaImgTipos = "Images/Tipos/";
public static string rutaImgTipos2 = "Images/";
public static Sprite imgTipo1 = Resources.Load<Sprite>((rutaImgTipos2+"Tipo1").Trim());
Could someone help me??
Thanks!
You need to check if the sprints are at the right place in your project
Hi,
I solved the problem.
The problem was that in android i cant see a public static Sprite for some reason, but first i put these sprites in a sprite arraylist all works.
I dont understand why the first metod works in unity but no in android...
THAN$$anonymous$$S!
Answer by sethuraj · Oct 02, 2013 at 08:09 PM
Your texture should be in a folder named 'Resources' for Resources.Load() to work or else it will work ony in editor not in build.Some thing like this will do.
Texture path - "Assets/Resources/MyTexture"
In code you can avoid the 'Assets' part
public void setTipTextTexture(string texture)
{
texture="TipTexts/"+texture;
this.tipTexture=(Texture)Resources.Load(texture,typeof(Texture));
}
Hope this helps!
I think don't need put "Resoucers" into code, because when you use the Resouces.Load(), it finds the texture in this folder automatically.
$$anonymous$$y problem was solved, but i didn't know how! Simply I tested again and was already working. However, thank you for help.
sorry my mistake.No "Resources/" needed.Corrected it.Thanks!!
Your answer
![](https://koobas.hobune.stream/wayback/20220613115054im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Touch: works on Unity-Remote, doesn't work on Android device after building 2 Answers
KeyNotFoundException: The given key was not present in the dictionary. 1 Answer
How to extend Activity (Android)? 1 Answer
How to assign a GUISkin using code only? 1 Answer
How to set Android keyboard to capitalize each word 0 Answers