I am trying to make a very basic menu, but it wont work as it should. I am using a slightly modified version of the swichcamera (or something like that…) script from the wiki. I am trying to disable the main menu camera (the camera with the main menu GUI) and enable the instructions camera (the camera with the instruction GUI) when teh user presses a GUI button. The script is attached to the main menu camera. Here is the code I am using:
var CustomGUI : GUISkin;
var MenuCamera : Camera;
var InstructionCamera : Camera;
var OnMainMenu = true;
function Start () {
MenuCamera.enabled = true;
InstructionCamera.enabled = false;
}
function Update () {
if (OnMainMenu == true) {
MenuCamera.enabled = true;
InstructionCamera.enabled = false;
}
if (OnMainMenu == false) {
MenuCamera.enabled = false;
InstructionCamera.enabled = true;
}
}
function OnGUI () {
GUI.skin = CustomGUI;
// 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.
// We'll make a box so you can see where the group is on-screen.
GUI.Box (Rect (0,0,100,100), "Main Menu");
if (GUI.Button (Rect (10,20,80,30), "Start game")){
Application.LoadLevel(1);
}
if (GUI.Button (Rect (10,55,80,30), "Instructions")){
OnMainMenu = false;
}
// End the group we started above. This is very important to remember!
GUI.EndGroup ();
}
Thanks in advance, you guys are awsome:)