- Home /
GUI.button Texture shows up in Unity but doesn't show on android device.
Hi,
I am trying to make a pause button and put it on the top left corner of my game.
So I did:
Texture2D pauseImage= (Texture2D)Resources.LoadAssetAtPath("..../somepic.png", typeof(Texture2D));
private GUIStyle clearStyle = new GUIStyle();
if (GUI.Button(new Rect(0, 0, 60, 60), pauseImage, clearStyle)) {
isPause = !isPause;
}
My button shows up and works fine in the Unity simulator. But when I deploy the game to my phone, the button become invisible and the image of the pause button is not loaded. I am wondering what could be the cause of this?
Thanks in advance.
Comment
Answer by _travistx · Aug 18, 2014 at 04:30 AM
LoadAssetAtPath only works in the unity editor. You want Resources.Load.
A few other tips, you will want to place your image in a folder called Resources. You will not be able to go up a directory like what it looks like you may be trying to do. You will also want to drop the .png suffix in your Resources.Load() statement.