Renderer.sharedMaterials 共享材质列表

var sharedMaterials : Material[]

Description描述

All the shared 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 sharedMaterials contains all the materials. sharedMaterial and material properties return the first used material if there is more than one.

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

Modifying any material in sharedMaterials will change the appearance of all objects using this material, and change material settings that are stored in the project too.

在sharedMaterials修改任意材质,将改变所有物体使用这个材质的外观,并且也改变储存在工程里的材质设置。

It is not recommended to modify materials returned by sharedMaterial. If you want to modify the material of a renderer use material instead.

不推荐修改由sharedMaterial返回的材质。如果你想修改渲染器的材质,使用material替代。

using UnityEngine;
using System.Collections;

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

参见: material, sharedMaterial properties.

最后修改:2010年12月17日 Friday 18:05

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。