Using Unity's Projector LightProjector there is a Main Color setting in the editor. I don't see any MainColor property in the Projector class. How can I change this in code?
1 Answer
I don't see "Color" property in Projector. There is only material, so you should probably change color in material.
material.color = desiredColor;
or
material.SetColor("shader_property_name_here", desiredColor);
if the shader property name is different then "_Color"
2 Comments
user441521
I tried the material.color way and it didn't work. Interestingly enough in the editor when I add 2 or more BlobLightProjector prefabs and change the color in one it changes it in all others. That's not desirable and I'm not sure how to stop that from happening.
Paweł Łęgowski
Because the color is in material that is shared among multiple objects. If you want to change color only in one object you should make sure your material is Instantiated. Lets say: Projector proj; void Awake(){ proj.material = new Material(proj.material); //and its instantiated so the color won't be shared any more }