- Home /
Can't animate Material.Color properties
Hi! I've got an object fade out animation and it's working fine on Animation Type 2. But on this type it's playing automatically and I can't edit it. But when I mark it as legacy it the color properties aren't work (when I animate other properties, transform.position for example all is working fine).
I'm not sure that it isn't the bug (Issue Tracker Link).
Please help if you know what I'm doing wrong.
Answer by musaranya · Jul 05, 2014 at 09:42 AM
For animating the color property of your objects you can do the following:
select the material used by your object in order to see its properties in the inspector
at the right of the shaders dropdown click on the Edit button. It will open the shader source code in your code editor
look at the top of the code, there are the properties used by the shader. For example if a shader shows in the inspector a property called Main Color, you will see something like this in the source code: _Color ("Main Color", Color) = (.5,.5,.5,1)
in order to change this Main Color property from your script, you should do something like this renderer.material.SetColor("_Color",yourColor). As you can see you must submit to SetColor() the name of the property according to the source code of the shader
you also can lerp this color for enhancing visuals, it's easy and free using iTween :)
Hope it helps
Answer by flaviusxvii · Jul 04, 2014 at 05:41 PM
Here's how I tackled changing color over time. Hope it helps.
Sorry, but I;m searching for hint, not for complete script. However I want use this, but I don't understand it and I've got a problem: $$anonymous$$aterial doesn't have a color property "_TintColor".
I usually don't provide full scripts.. and I considered this one a hint because I was pretty sure you couldn't just use it directly. It was meant as a guide. I use a material where the color is called "_TintColor". You'll want to change that to whatever matches the material you plan to use. Or you could make a variable you could fill-in in the inspector.
Answer by EpicCubeGroup · Oct 17, 2016 at 08:07 AM
To simply animate colors over time (for ANY material property), you could consider to use Color Transition Package. We've implemented a set of components that allow users (artists and programmers) to simply create color animations from editor and from code. Here it's the link to the official page: http://alexandros.altervista.org/blog/color-transition-package-for-unity-3d/ and to the Asset Store: http://u3d.as/Bmr bye
Your answer
Follow this Question
Related Questions
Changing two different objects renderer colour 1 Answer
Material doesn't have a color property '_Color' 4 Answers
Fade out a material that has a texture 1 Answer
Array breaking when pushing floats into it via a for loop. 2 Answers
Editing alpha through a script and animation changes the colour not the transparency? 1 Answer