- Home /
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?
Answer by nsxdavid · Mar 23, 2013 at 03:51 PM
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.
As I said, The fading works.
The shader I'm using to fade the object does have the _Color property.
That's way I don't it's weird.
One thing to try is to modify iTween so that that error message gives you more information, like what gameObject / $$anonymous$$aterial it is not happy about.
I'm not sure how to do that.
Can you help?
edit:
Ok, so I figuerd out what is giving the errors.
It's the particle systems.
I didn't know iTween will try to effect them as well.
Thanks for your help.
Answer by robertbu · Mar 23, 2013 at 04:10 PM
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.
As I said, The fading works.
The shader I'm using to fade the object does have the _Color property.
All the objects have only one material.
It's like there is a hidden gameobject, But I checked, there isn't one....
Answer by maaton · Nov 25, 2014 at 04:31 PM
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));
Answer by Apoll0 · May 04, 2016 at 07:35 AM
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