my problem is that I want to make 2 GUI buttons apear when the player clicks on a button one saying “New Game” and the other “Continue” can some one pls help me
the code I used is :
var levelToLoad : String;
var soundhover : AudioClip;
var beep : AudioClip;
var QuitButton : boolean = false;
function OnMouseEnter(){
audio.PlayOneShot(soundhover);
}
function OnMouseUp(){
audio.PlayOneShot(beep);
yield new WaitForSeconds(0.35);
if(QuitButton){
Application.Quit();
}
else{
function OnGUI(){
// Make a group on the center of the screen
GUI.BeginGroup (Rect (Screen.width / 2 - 50, Screen.height / 2 - 50, 100, 100));
// All rectangles are now adjusted to the group. (0,0) is the topleft corner of the group.
// make a box for group
GUI.Box (Rect (0,0,100,100), "Game Options");
GUI.Button (Rect (10,40,80,30), "New Game");
GUI.Button (Rect (10,50,80,30), "Continue");
// End the group we started above
GUI.EndGroup ();
}
}
@script RequireComponent(AudioSource)
function OnGUI(){
if GUI.Button (Rect (10,0,80,30), "Button that triggers two more btns");
{
if GUI.Button (Rect (10,40,80,30), "New Game");
{
// code for New Game Button
}
if GUI.Button (Rect (10,80,80,30), "Continue");
{
// code for Continue button
}
}
}
This invokes a button that calls two more new buttons while pressed. PLEASE adjust the Rect coordinates in THIS code so they fit your own GUI design. Hope this helps you –if not, just let know Greetings from México.