Quantcast
Viewing latest article 16
Browse Latest Browse All 61

Answer by jamesflowerdew

you need this: renderer.material.SetColor ("_Color", color); dot syntax does not work with materials. also note `"_Color"` is the address of the `_Color` variable in a shader, if your material's shader uses another variable you'll need to find out what it wants. [edit (big edit ;)] just noted you CAN use dot syntax (thanks tanoshimi), although this presumes that the `_Color` variable exists at all. several shaders do not have the `_Color variable, and if you're using a custom shader, they could easily for instance call it `_Tint` or `_Colour`, etc. However I also note you're defining the variable at the beginning as Color color = renderer.material.color; I'm pretty sure that you can't initialise a variable with a get texture like this before any events. Try changing it to this. Color color; and setting the color in a start routine instead. void Start(){ color=renderer.material.GetColor("_Color"); }

Viewing latest article 16
Browse Latest Browse All 61

Trending Articles