Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Material.HasProperty

HasProperty(propertyName: string): bool;
HasProperty(nameID: int): bool;

Description

Checks if material's shader has a property of a given name.

	// Attach this to a gameObject that has a renderer.

if(renderer.material.HasProperty("_Color")) renderer.material.SetColor("_Color",Color.red);