I have a main menu, and a button using GUI.
I want that when the player click on the gui make a transition to another screen showing options.
How to make this?
I’m beginner at programming and need your help.
I have a main menu, and a button using GUI.
I want that when the player click on the gui make a transition to another screen showing options.
How to make this?
I’m beginner at programming and need your help.
I know two ways to do that.
if(GUI.Button(Rect(10, 10, 125, 25), "Options")) {
Application.LoadLevel(1);
}
var showMainMenu : boolean = true;
var showOptions : boolean = false;
function OnGUI() {
if(showMainMenu) {
// Main menu GUI code
}
if(showOptions) {
// Options GUI code
}
// Show options on button press
if(GUI.Button(Rect(10, 10, 125, 25), "Options")) {
showMainMenu = false;
showOptions = true;
}
}
I personally prefer second option, but choice is yours
Work 100% correctly .
Thank You!
UnityGUI menus should really be a part of the first scene only. There’s no reason why to separate it into multiple scenes. So, the second option is sure the best.
The first option should be taken into the account when using non-UnityGUI frameworks, i.e. when GUI elements are the part of the #D scene.