may first gui window opens via a toggle switch. but inside that window i would like a button or a toggole to open another. I hve tryed to use button and toggle but they both wont work. Can someone please help?
here is a copy of my code:
var windowRect : Rect = Rect (20, 40, 127, 70);
var windowRect2 : Rect = Rect (100,12, Screen.height , 70);
var doMenu : boolean = false;
var doFacer : boolean = false;
var icon : Texture2D;
var customSkin : GUISkin;
var target : Transform;
var place1 : Transform;
var place2 : Transform;
var place3 : Transform;
var place4 : Transform;
var place5 : Transform;
function OnGUI () {
GUI.skin = customSkin;
//menu button
doMenu = GUI.Toggle (Rect (10,10,100,20), doMenu, "Menu");
if (doMenu){
windowRect2 = GUI.Window (1, windowRect2, DoMyWindow2, " ");
}
//Menu Button End
}
// Make the contents of the window
function DoMyWindow (windowID : int) {
GUI.Label (Rect (6, 1, 2500, 20), "Object In Area");
if (GUI.Button (Rect (10,20,100,20), "Harvest")){
print ("Got a click");
target = place1;
}
if (GUI.Button (Rect (15,40,100,20), "-Moon Mounter")){
print ("Got a click");
target = place2;
}
GUI.DragWindow (Rect (0,0,10000,10000));
}
function DoMyWindow2 (windowID : int) {
GUI.Label (Rect (6, 1, 2500, 20), "Menu");
GUI.DragWindow (Rect (0,0,10000,10000));
if (GUI.Button (Rect (15,40,100,20), "Facer")){
windowRect = GUI.Window (0, windowRect, DoMyWindow, "");
}
}
function Update () {
var targetPoint = target.position;
var targetRotation = Quaternion.LookRotation (targetPoint - transform.position, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 2.0);
}
Thanks in advance, Lachee