Something like a dynamic struct

Hi there.

I made a script to toggle lights with GUI Buttons. The things is, I want to set ALL the parameters to be dynamic. If I want to handle 1 light or 100 lights I just need to change the “Size” property in the Inspector.

Its something like a Array of Structs. Like:
Position1:
Button_x = 10;
Button_y = 20;
LightObj = XXX;

Position2:
Button_x = 10;
Button_y = 40;
LightObj = YYY;

The script so far (just handles 1 light at a time):

var button_x : float = 10;
var button_y : float = 10;
var button_w : float = 150;
var button_h : float = 30;
var button_t : String = "Toggle Light";
var objLight : GameObject;

function OnGUI () {

	if (new GUI.Button(Rect(button_x,button_y,button_w,button_h),button_t))
	{
		var _light : Light = objLight.GetComponent(Light);
		_light.enabled = !_light.enabled;
	}

}

I want to use this script once in a “GUIManager” or something like, and set all the lights and buttons that I want to create.
There’s any way to do it?

Tx.

Sorry about that…

Just found the answer at http://forum.unity3d.com/viewtopic.php?t=56286&highlight=struct when searching for “STRUCT”.

For those with the same doubt, here’s my script:

class LightList {
   var button_x : float = 10;
	var button_y : float = 10;
	var button_w : float = 150;
	var button_h : float = 30;
	var button_tOn : String = "Turn light OFF";
	var button_tOff : String = "Turn light ON";
	var objLight : GameObject;
}

var lightArray = new LightList[1];

function OnGUI () {
	for (var i : int = 0;i<lightArray.length;i++)
	{
		var _light : Light = lightArray[i].objLight.GetComponent(Light);
		var button_t : String = _light.enabled ? lightArray[i].button_tOn : lightArray[i].button_tOff;
		if (new GUI.Button(Rect(lightArray[i].button_x,lightArray[i].button_y,lightArray[i].button_w,lightArray[i].button_h),button_t))
		{
			
			_light.enabled = !_light.enabled;
		}
	}

}