You could do it using functions. Something like this:
public var currentMenu : string = "";
function Start() {
currentMenu = "window1";
}
function OnGUI() {
if(currentMenu == "window1")
Window1();
if(currentMenu == "window2")
Window2();
}
function NavigateTo(string nextmenu) {
currentMenu = nextmenu;
}
function Window1() {
if(GUI.Button(new Rect(10, 10, 200, 50), "To next window")) {
NavigateTo("window2");
}
}
function Window2() {
if(GUI.Button(new Rect(10, 10, 200, 50), "To previous window")) {
NavigateTo("window1");
}
}
I'm not sure if this will work correctly in Javasctript, it works in C# though. Just add each window in the OnGUI and give it a string, the make a function for it and add your GUI elements to the function and use the NavigateTo function to navigate to it. Hope it works for you.
↧