- Home /
Combinning light shading and slider?
Hello Unity community,
I'm kind new with scripting and I'm trying to make a slider to shade or brighten the light.
I have a script for shading the light and another to do a slider but I can't manage to combine the 2 of them. An idea?
Here is the script for the light shading:
light.intensity = 0.85;
function Update(){ if(Input.GetKeyDown("f")){ gameObject.light.intensity += 0.1; } if(Input.GetKeyDown("c")){ gameObject.light.intensity -= 0.1; }
}
Here is the script for the slider:
var hSliderValue : float=0.0; light.intensity = 0.85;
function OnGUI(){ hSliderValue = GUI.HorizontalSlider (Rect(25,25,100,30), hSliderValue, 0.0,8.0); }
Thanks in advance!
Answer by Aurorem · Nov 06, 2012 at 01:30 PM
Solved! Here is the code I used if someone is interested:
private var slide : float=4;
function Update ()
{
light.color = Color(1.160,1.275,1.275) * 0.2 *slide;
}
function OnGUI () {
GUI.Box (Rect(Screen.width - 100,206,100,40), "Light intensity");
slide = GUI.HorizontalSlider (Rect (Screen.width - 100,228,100,40), slide, 0.0,8.0);
}
Your answer
Follow this Question
Related Questions
How to access the lights properties from within a shader? 1 Answer
Shader: Changing a Ramp Size 1 Answer
Customize slider in Shader 3 Answers
Shader for Overlapping LIghts 0 Answers