- Home /
GUI.Box not showing Texture on device
I'm using GUI.Box in order to show the items status of my main character. It works well when I test it in Unity's simulator but the Texture doesn't even show in a real device. I've tried using both Texture and GUITexture but none of them works.
I'm using Resources.Load and this can be part of the problem. Here's the function I call the textures from:
Texture loadTextureFromString(string name)
{
string path = "Assets/GUI/items/" + name + ".PNG";
return Resources.LoadAssetAtPath(path, typeof(Texture)) as Texture;
}
Or the equivalent changing the texture files type to GUI and writing GUITexture instead of Texture.
And, my OnGUI()
function looks like this:
void OnGUI()
{
Texture itemDisplayed = loadTextureFromString(someStringVariableThatChanges);
GUI.Box(new Rect(kX, kY, kWidth, kHeight), itemDisplayed, GUIStyle.none);
}
Any idea of how to solve this issue? Thanks a lot.
Answer by gheeler · Jul 17, 2013 at 10:24 AM
Resources.LoadAssetAtPath only work in the editor
User Resources.Load("GUI/" + name);
and put your image in folder called Resources
Does that mean that the image has to be in the path GUI/Resources/image.PNG
or that it should be in Resources/GUI/image.PNG
?
Resources/GUI/Items/image.png or whatever folder structure you want. dont include the .png in your string
Your answer
Follow this Question
Related Questions
GUI.DrawTexture on GUI.Button press 1 Answer
Another Inventory Script with pictograms 0 Answers
GUITexture HitTest not registering 0 Answers