Ok, I’ve found the culprit. It’s the “if (objects[object] == “1”) {}” statement in this code:
private var objects = new Array();
private var object : int;
private var actions = new Array();
function Start () {
objects = ["1", "2", "3"];
actions = ["one", "two", "three"];
}
function OnGUI () {
var utObjects = objects.ToBuiltin(String); // so you can modify the objects list and make the GUI grid work
object = GUI.SelectionGrid (Rect (0, 0, 300, 300), object, utObjects, 1);
if (objects[object] == "1") {
GUILayout.BeginArea (Rect (300,0,300,300));
for (action = 0; action < actions.length; action++) {
if (GUILayout.Button(actions[action], GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) {
}
}
GUILayout.EndArea ();
}
}
Just click on 2 or 3 and then select 1 again, and you will get the errors. Now, the code works fine if I use the non-GUI Layout method found here:
private var objects = new Array();
private var object : int;
private var actions = new Array();
function Start () {
objects = ["1", "2", "3"];
actions = ["one", "two", "three"];
}
function OnGUI () {
var utObjects = objects.ToBuiltin(String); // so you can modify the objects list and make the GUI grid work
object = GUI.SelectionGrid (Rect (0, 0, 300, 300), object, utObjects, 1);
if (objects[object] == "1") {
var buttonHeight = 300 / actions.length;
for (action = 0; action < actions.length; action++) {
var buttonTop = action * buttonHeight;
if (GUI.Button(Rect (300, buttonTop, 300, buttonHeight), actions[action]) ) {
}
}
}
}
But once again, I am trying to incorporate the Margin setting for the buttons, and I am hoping that the Layout method will allow that, because my current, otherwise functional method, does not. Please let me know if a bug report is still in order, or if there is a way to fix this.