Material.CopyPropertiesFromMaterial 从材质拷贝属性

function CopyPropertiesFromMaterial (mat : Material) : void

Description描述

Copy properties from other material into this material.

拷贝其他材质的属性到这个材质

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Material mat;
	public void Awake() {
		if (!typeof(mat)) {
			Debug.LogError("Assign a material on the inspector.");
		return;
		}
			renderer.material.CopyPropertiesFromMaterial(mat);
	}
}
// Attach this to a gameObject that has a renderer.
//把它附加在有renderer组件的游戏物体(gameobject)上
// Copies any property mat has and assigns it to this transform material
// 拷贝所有属性并将它分配给此转换材质

var mat : Material;

if (!mat) {
	Debug.LogError ("Assign a material on the inspector.");
	return;
}

renderer.material.CopyPropertiesFromMaterial(mat);
Page last updated: 2011-1-22