- Home /
Material doesn't have a color property '_Color'
Hi, my console write me this error: Material doesn't have a color property '_Color' UnityEngine.Material:get_color() material_switch:Start() (at Assets/Scripts/CS script/material_switch.cs:14) But i dont know what is it. Any idea how to fix it? here is my source code:
using UnityEngine;
using System.Collections;
public class material_switch : MonoBehaviour {
public Material original_material;
public Shader original_shader;
public Color original_color;
public Material edit_material;
public void Start () {
original_material = transform.renderer.material;
original_shader = transform.renderer.material.shader;
original_color = transform.renderer.material.color;
}
public void restoreMaterial() {
transform.renderer.material = original_material;
transform.renderer.material.color = original_color;
transform.renderer.material.shader = original_shader;
}
public void saveMaterial() {
original_material = transform.renderer.material;
original_shader = transform.renderer.material.shader;
original_color = transform.renderer.material.color;
}
public void setEditMode() {
transform.renderer.material = edit_material;
transform.renderer.material.shader = Shader.Find ("Diffuse");
transform.renderer.material.color = new Color32(72,114,19,255);
}
}
Thanks
Kind regards Thomas
To copy and paste this script to my editor reproduces no errors.
$$anonymous$$ake sure your gameobject actually has a material assigned.
Answer by robertbu · Aug 17, 2014 at 02:14 PM
Not all shaders support main color. First check the material. You should see a color selection tool on the right and on the left you will usually see "Color" or "Main Color". If your material does have a color selection box, then it does not support color. If you have a selection box, open the shader and see if that color is named _Color.
Only a fraction of the shaders that ship with Unity have a _Color property.
yes, i know that yet :D i had a lot of free time fot this problem, and i solved that :) but so thnaks for your time and helpful message.
Answer by OZAV · Jul 09, 2016 at 07:35 AM
As many will still bump into this thread (and no threads on Unity issues will ever be old):
-Just try using some of shaders under: Particles - "Additive" or any of them, in the particles-"additive" list of shaders ...