- Home /
check shader property if exist
how can check if propery in shader exist?
i tryed :
if != null
try
every time, i get error
Material doesn't have a texture property '_MainTex'
UnityEngine.Material:get_mainTexture()
Comment
Answer by DaveA · Oct 22, 2012 at 11:14 PM
http://docs.unity3d.com/Documentation/ScriptReference/Material.HasProperty.html
if(renderer.material.HasProperty("_Color")) renderer.material.SetColor("_Color",Color.red);
Your answer
![](https://koobas.hobune.stream/wayback/20220613082744im_/https://answers.unity.com/themes/thub/images/avi.jpg)