- Home /
Change a color from shader using JS script
Hello;
have created a shader script here's a part of it
Properties
{
_SunColor("Sun Color of Light", Color) = (0.977612,0.9254484,0.882769,1)
}
I'd like that the script would be like that :
//
var colorObject : GameObject;
var theColor : Color;
function Start () {
theColor = colorObject.light.color;
}
function Update () {
this.renderer.material.Sun_Color_of_Light = theColor;
}
//End of script
The "colorObject" variable is a GameObject with Light (like direction light)
My question is how can I make the color that I've mentioned in my shader script being able to be changed with the variable "theColor"
Sorry if I wasn't very clear with my question
Thanks, your help would be great ;)
Answer by ExtremePowers · Oct 07, 2014 at 08:00 PM
Is it something like this you are looking for? http://docs.unity3d.com/ScriptReference/Material.SetColor.html
Answer by tanoshimi · Oct 07, 2014 at 08:05 PM
this.renderer.material.SetColor("_SunColor", theColor);
Your answer
Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
Rendering only specific colors? Color filter? 1 Answer
How can I add a color, smoothness and metallic property to this shader? 1 Answer
Is there any way to get negative color in this shader? 0 Answers
Simple vertex color + light shader 1 Answer