Making an Image appear in Javascript on Page

#pragma strict

var Novice: GUIStyle;







function Start ()

{

           PlayerPrefs.SetInt("Costumes", 0);

}




function Update ()

{




}




function OnGUI()

{




}




{

if (PlayerPrefs.GetInt("Costumes", 0))




{

 

  (GUI.Button (new Rect (Screen.width/4.95f,Screen.height/1.15, Screen.width/10.9f,Screen.height/9.2f),"",Novice));

}

}

Unity says the script has no errors but how come once I attach the script then attach the picture to Novice when I press play the Novice picture wont appear on that part of the screen - Help would be much appreaciated :slight_smile:

if (PlayerPrefs.GetInt("Costumes", 0))

don’t you mean

if (PlayerPrefs.GetInt("Costumes")==0)
function OnGUI()
{

}


{

    if (PlayerPrefs.GetInt("Costumes")==0)

{
 
     (GUI.Button (new Rect (Screen.width/4.95f,Screen.height/1.15, Screen.width/10.9f,Screen.height/9.2f),"",Novice));

}
    }

Still doesn’t seem to make it appear on the screen :S

Line 3 in your original post says that Novice is a GUIStyle. That is perfectly correct code, but I doubt it’s what you want. Maybe you mean Novice to be a Texture, and to pass that in as the second argument to GUI.Button? Since you’ve not really explained what you are trying to do, it’s hard to give you concrete advice. And the code in your last post is completely borked - you have a closing brace at line 4, which means the code that follows is just floating in space.

Im making a game on Android and I have a figure but he has all different kinds of costumes, I want the costumes to change depending on the PlayerPref Costume, because if I just put him on the screen depending on peoples mobile sizes it will screw up where he is like images did on my old game. but it seems using GUI.Button makes it the perfect size and puts it in the perfect area on peoples Mobile Phones.

Hmm you noticing that { and } that where there just floating I deleted that and it seemed to fix it O.o - thanks for pointing that out :slight_smile: