Hi,
Thanks for the help. So I dragged the respective objects from the heirarchy menu into the inspector window. Here’s my code:
//show gui in edit mode
@script ExecuteInEditMode
var blckbox : GUIStyle;
var appBug : GUIStyle;
var SSGButton : GUIStyle;
var AGSButton : GUIStyle;
var nextButton : GUIStyle;
var prevButton : GUIStyle;
var product1Button : GUIStyle;
var product2Button : GUIStyle;
var product3Button : GUIStyle;
var product4Button : GUIStyle;
var product5Button : GUIStyle;
var product1 : GameObject;
var product4 : GameObject;
var product2 : GameObject;
var product3 : GameObject;
var product5 : GameObject;
function OnGUI () {
GUI.matrix = Matrix4x4.TRS (Vector3(0,0,0), Quaternion.identity, Vector3 (Screen.width / 1600.0, Screen.height / 1200.0, 1/1));
GUI.Box (Rect (0,0,260,1500), "", blckbox);
GUI.Box (Rect (33,0,130,59), "",appBug);
//if (GUI.Button (Rect (543,17,193,37), "SSGButton", SSGButton)) print ("SSG");
//if (GUI.Button (Rect (754,17,193,37), "AGSButton", AGSButton)) print ("AGS");
// if (GUI.Button (Rect (754,182,193,37), "", nextButton)) print ("NEXT");
// if (GUI.Button (Rect (543,182,193,37), "", prevButton)) print ("PREVIOUS");
if (GUI.Button (Rect (33,100,192,144), "", product1Button)) print ("product1");
product1.SetActiveRecursively(true);
product2.SetActiveRecursively(false);
product3.SetActiveRecursively(false);
product4.SetActiveRecursively(false);
product5.SetActiveRecursively(false);
if (GUI.Button (Rect (33,300,192,144), "", product2Button))print ("product2");
product1.SetActiveRecursively(false);
product2.SetActiveRecursively(true);
product3.SetActiveRecursively(false);
product4.SetActiveRecursively(false);
product5.SetActiveRecursively(false);
if (GUI.Button (Rect (33,500,192,144), "", product3Button)) print ("product3");
product1.SetActiveRecursively(false);
product2.SetActiveRecursively(false);
product3.SetActiveRecursively(true);
product4.SetActiveRecursively(false);
product5.SetActiveRecursively(false);
if (GUI.Button (Rect (33,700,192,144), "", AeraButton)) print ("product4");
product1.SetActiveRecursively(false);
product2.SetActiveRecursively(false);
product3.SetActiveRecursively(false);
product4.SetActiveRecursively(true);
product5.SetActiveRecursively(false);
if (GUI.Button (Rect (33,900,192,144), "", product5Button)) print ("product5");
product1.SetActiveRecursively(false);
product2.SetActiveRecursively(false);
product3.SetActiveRecursively(false);
product4.SetActiveRecursively(false);
product5.SetActiveRecursively(true);
}
However, when I press play, it loads product 5 automatically and there’s no button functionality. do I not want to use the SetActiveRecursively command for each button? I thought the purpose of this command was to set the target gameobject to be active (if true) and inactive (if false). many thanks!
d