Renderer.materials 材质列表

var sharedMaterials : Material[]

Description描述

All the materials of this object.

物体的全部材质。

This is an array of all materials used by the renderer. Unity supports a single object using multiple materials; in this case materials contains all the materials. sharedMaterial and material properties return the first used material if there is more than one.

由渲染器使用的所有材质的一个数组。Unity支持单个物体使用多个材质,在这种情况下在Materials包含所有的材质,如果有一个以上的材质,sharedMaterialmaterial属性返回首次使用的材质

Modifying any material in materials will change the appearance of only that object.

在materials修改任意材质,将改变只是物体的外观。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		print("I'm using " + renderer.materials.Length + " material(s)");
	}
}
print ("I'm using " + renderer.materials.Length + " material(s)");

参见: material, sharedMaterial properties.

Page last updated: 2010-12-17