Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

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

Material.HasProperty

public function HasProperty(propertyName: string): bool;
public function 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);