Change a color from shader using JS script

Hello;

I 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 :wink:

Does the code you have not work?

2 Answers

2

Is it something like this you are looking for?

Yes, that's what i was locking for Thanks

this.renderer.material.SetColor(“_SunColor”, theColor);

Thanks, that helps me a lot