[Solved]GUI won't pop out

so basically i want to pop up some gui…
and here’s my code…

var button1 : GUIStyle;
var button2 : GUIStyle;
var popUp1: Texture;
function Start () {

}
function OnGUI(){
	if(GUI.Button(new Rect(Screen.width*0.5,Screen.height*0.1,Screen.width*0.4,Screen.height*0.2)," ",button1)){
		print("a");
		GUI.DrawTexture(Rect(Screen.width*0.4,Screen.height*0.4,Screen.width*0.5,Screen.height*0.5),popUp1);
		print("b");
	}
	
	GUI.Button(new Rect(Screen.width*0.5,Screen.height*0.3,Screen.width*0.4,Screen.height*0.2)," ",button2);

	
}

in the console it printed “a” and “b” but, the the game doesn’t Draw the “popUp1” Texture. does my code is wrong or something? thanks for further help :slight_smile:

It draws the texture… but only for one frame. What you have to do is to switch any value (in most cases a boolean) so that unity “knows”: From now on in all the frames you should draw the Texture. Do something like:

    var button1 : GUIStyle;
    var button2 : GUIStyle;
    var popUp1: Texture;
var ispopingUp :boolean;
    function Start () {
     
    }
    function OnGUI(){
    if(GUI.Button(new Rect(Screen.width*0.5,Screen.height*0.1,Screen.width*0.4,Screen.height*0.2)," ",button1)){
    print("a");
    ispopingUp = true;
    print("b");
    }
     
    GUI.Button(new Rect(Screen.width*0.5,Screen.height*0.3,Screen.width*0.4,Screen.height*0.2)," ",button2);
     
     
	if(ispopingUp)
{
	GUI.DrawTexture(Rect(Screen.width*0.4,Screen.height*0.4,Screen.width*0.5,Screen.height*0.5),popUp1);
}

    }

(Sorry for bad formatting :wink: )