Hi all, I am just learning Unity 3 and I am finding the learning curve quite steep for me.
At this point of time, I've managed to do up a decent GUI interface with GUIskin and GUI Group. If let's say I would like to make the whole GUI group slide out of the menu upon keypress(spacebar), which command should I be using? Am I doing it right in the first place because I can't seem to get the whole GUI Group to move on keypress.
Below is my code:
@script ExecuteInEditMode()
//This command is to run your GUI scripts without having to play the scene
//variable for GUISkin var customSkin : GUISkin;
var icon : Texture;
var plate : Texture;
//Slider default values when you first run Unity. var slider = 50;
//var windowRect : Rect = Rect (20, 20, 120, 50);
function OnGUI () {
//applies skin to all. any GUI elements above this script will not get "skinned". GUI.skin = customSkin;
//Everything in a group will move accordingly is you adjust the x and y values. GUI.BeginGroup (Rect (Screen.width/2-480,Screen.height/2-240, 960,480 ));
// We'll make a box so you can see where the group is on-screen.
//GUI.Box (Rect (0,0,960,480), "Interface Group 1");
GUI.Label (Rect ( 0, 0, 960, 480), plate);
//To set the button to load levels, add your scenes from the Build Settings. if (GUI.Button (Rect (60,25,80,30), "Level 1")) { Application.LoadLevel (1); }
GUI.Button (Rect (280,25,80,30), "Button 2");
GUI.Button (Rect (500,25,80,30), icon);
GUI.Label (Rect (760, 135, 128,128),icon);
// End the group we started above.
GUI.EndGroup ();
}
//////What command should I use here for the keypress function?/////////////
function Update () { if (Input.GetKeyDown (KeyCode.Space)){
print ("space key was pressed");
//(command to use here?);
}
}