Documentation

Unity Engine

Unity Engine

GetMaterialProperty

Obtains information about a shader property, identified by name, for a set of materials.
Read time 1 minuteLast updated 20 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule

GetMaterialProperty(Object[], string)

Obtains information about a shader property, identified by name, for a set of materials.
public static MaterialProperty GetMaterialProperty(Object[] mats, string name)

Parameters

The materials to get the property for.

name

The name of the shader property, for example
_Color
.

Returns

Type

Description

MaterialPropertyThe material property with the specified name.

Remarks

When you implement a custom material editor, pass
this.targets
to this method to get the property for all the selected materials. The method throws an exception if
mats
is null or contains a null element.

GetMaterialProperty(Object[], int)

Obtains information about a shader property, identified by index, for a set of materials.
public static MaterialProperty GetMaterialProperty(Object[] mats, int propertyIndex)

Parameters

The materials to get the property for.

propertyIndex

The index of the property in the shader.

Returns

Type

Description

MaterialPropertyThe material property at the specified index.

Remarks

When you implement a custom material editor, pass
this.targets
to this method to get the property for all the selected materials. The method throws an exception if
mats
is null or contains a null element.