Hi everyone,
I’m making a sample test on switching an on/off multiple lights using 1 GUI button. Right now I’m using javascript because I’m still learning unity. Could anybody give me some sample codes that I’ could use. Thanks.
Hi everyone,
I’m making a sample test on switching an on/off multiple lights using 1 GUI button. Right now I’m using javascript because I’m still learning unity. Could anybody give me some sample codes that I’ could use. Thanks.
That should do it.
var lights : Light[];
function OnGUI()
{
var on = lights[0].enabled;
if( GUI.Button( Rect( 10, 10, 100, 100 ), "Turn " + (on ? "off" : "on") + " the lights !" ) )
{
for( var i = 0; i < lights.Length; i++ )
lights*.enabled = !on;*
}
}