Hello, I'd like to ask how do I change the color of a light (sunlight) via a slider?
Say, I have a specific set of colors that I want the slider to change the light's color to when it reaches a certain value.
Example: At value 0, the color is light blue; at value 50, the color is orange; at value 100, the color is purple.
I came up with this script, but it doesn't seem to work; the color doesn't really change. If someone could point me in the right direction on how to work around this?
var lights : Light[];
var Sunlight : Light;
var SunColorSliderValue : float = 0.0;
var SunColors : Color[];
var guiSkin : GUISkin;
var toggleBoolSUN : boolean = true;
private var toggleRect = Rect(15, 20, 135, 45);
function OnGUI ()
{
GUILayout.BeginArea( Rect( 10, 410, 240, 180 ),GUI.skin.window);
toggleBoolSUN = GUI.Toggle(toggleRect, toggleBoolSUN, "Sunlight", guiSkin.button);
lights[0].enabled = toggleBoolSUN;
if(toggleBoolSUN)
{
SunColorSliderValue = GUI.VerticalSlider(Rect(185,65,30,100), SunColorSliderValue, 0, 100);
}
Sunlight.color = SunColorSliderValue;
if(SunColorSliderValue == 0)
{
Sunlight.color = SunColour[0];
}
if(SunColorSliderValue == 50)
{
Sunlight.color = SunColour[1];
}
if(SunColorSliderValue == 100)
{
Sunlight.color = SunColour[2];
}
GUILayout.EndArea();
}
Thanks for the help! =)