- Home /
How can I make a gui with buttons pop up in javasript?
I am wanting to be able to hit "B" and a gui come up with buttons inside. Can someone help me in doing this?
Answer by goo-muffin · Sep 13, 2012 at 02:22 PM
#pragma strict var buttonName :String; private var act :boolean; var closeOnButton :boolean; //Should it close again when you press b? function Start () {
}
function Update () { if(Input.GetKeyDown(buttonName)){ if(closeOnButton){ if(act){ act = false; }else act = true; }else{ act = true; } } }
function OnGUI(){ if(act){ GUI.Box(Rect(Screen.width / 4, Screen.height / 4, Screen.width / 2, Screen.height / 2), ""); //Background Box GUI.Button (Rect(Screen.width / 4 + 15, Screen.height / 4 + 15, Screen.width / 2 - 30, Screen.height / 4 - 15), "A Button here. \nJust add more if u want"); } }
Your answer
Follow this Question
Related Questions
Make button clickable 2 Answers
Touch Control Android Java 0 Answers
Can't get 4.6 GUI Button to Load Scene (Solved) 1 Answer
Select a game object and perform actions using GUI.Button (EventTrigger) 2 Answers
I have doubt please help me 2 Answers