function HasProperty (propertyName : string) : bool
Description
Checks if material's shader has a property of a given name.
See Also: Materials, ShaderLab documentation.
if(renderer.material.HasProperty(
"_Color"))
renderer.material.SetColor(
"_Color",
Color.red);
using UnityEngine;
using System.Collections;
public class example :
MonoBehaviour {
void Awake() {
if (renderer.material.HasProperty(
"_Color"))
renderer.material.SetColor(
"_Color",
Color.red);
}
}
import UnityEngine
import System.Collections
class example(
MonoBehaviour):
def
Awake():
if renderer.material.HasProperty('_Color'):
renderer.material.SetColor('_Color',
Color.red)