Version: 2017.1
public Material[] materials ;

描述

返回该对象的所有实例化材质。

此为渲染器使用的所有材质的数组。Unity 支持单一对象使用多种材质; 在这种情况下,materials 包含所有材质。 如果有多个材质,sharedMaterialmaterial 属性返回第一个 使用的材质。

修改 materials 中的任何材质都只会更改该对象的外观。

注意,与 Unity 返回的所有数组一样, 这将返回材质数组的副本。若要更改其中的某些材质,请获取值、更改条目, 然后重新设置材质。

Note:
This function automatically instantiates the materials and makes them unique to this renderer. It is your responsibility to destroy the materials when the game object is being destroyed. Resources.UnloadUnusedAssets also destroys the materials but it is usually only called when loading a new level.