Material doesn't have property '_Color'

Hello everyone.

I’m having a really weird problem.

I have a character that has skinned mesh renderer and on the hand bone I have a gun with a mesh renderer.

I also have two particle systems under the parent gameobject.

I’m using iTween.FadeTo to fade all children of the gameobject (character & gun), and it works perfectly.

Both the character and the gun start with the default diffuse shader.

Before I use the iTween.FadeTo, I’m changing their shaders to a shader That I found that can fade.

But for some reason I’m getting this error:

Material doesn’t have a color property ‘_Color’

From the iTween script.

Any ideas?

The Shader used by the material doesn’t have a property named _Color. Edit the shader to see how it works and what the internal property names are. They might have a color property but named it differently. Refactor to use the magic name _Color in the shader script to get it to work from iTween.

If you select the material in the Project pane, what properties does it show for the material? You may have to double click on the material header in the inspector to get it to open. iTween works with Main Color. Not all shaders have a Main Color (which is named _Color in the shader). So the solution is to switch to a different shader.

I’m not sure if/how iTween handles objects with multiple materials. It is possible there are multiple materials on the gun, and only some of them lack a _Color property.

By default iTween is trying to apply FadeTo() to the materials of the 2 children particleSystems as well, that’s why you’re getting this error. If you want to use ColorTo() or FadeTo() on a gameObject that is parent of any other gameobjects that have shaders without _Color property make sure you pass “includeChildren”,false to the targeted gameObject as a tween parameter.

iTween.FadeTo(gameObject,iTween.Hash(
“alpha”, targetAlpha,
“time”,animTime,
“includeChildren”,false));

Hello, @dorpeleg!
You can try to edit the iTween’s code, where:

if(target.GetComponent<GUITexture>()){
			tempColor=fromColor=target.GetComponent<GUITexture>().color;	
		}else if(target.GetComponent<GUIText>()){
			tempColor=fromColor=target.GetComponent<GUIText>().material.color;
		}else if(target.GetComponent<Renderer>()){
			tempColor=fromColor=target.GetComponent<Renderer>().material.color;
		}else if(target.GetComponent<Light>()){
			tempColor=fromColor=target.GetComponent<Light>().color;
		}

to

if(target.GetComponent<GUITexture>()){
			tempColor=fromColor=target.GetComponent<GUITexture>().color;	
		}else if(target.GetComponent<GUIText>()){
			tempColor=fromColor=target.GetComponent<GUIText>().material.color;
		}else if(target.GetComponent<Renderer>() && target.GetComponent<Renderer>().material.HasProperty("_Color")){
			tempColor=fromColor=target.GetComponent<Renderer>().material.color;
		}else if(target.GetComponent<Light>()){
			tempColor=fromColor=target.GetComponent<Light>().color;
		}

So, here you are checking the availability of “_Color” property