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.