Version: 2021.1

Material.CopyPropertiesFromMaterial

切换到手册
public void CopyPropertiesFromMaterial (Material mat);

描述

将属性从其他材质复制到此材质中。

此函数从其他材质复制属性值(运行时进行序列化和设置)以及着色器关键字、渲染队列和全局光照标志。材质的着色器不会更改。

using UnityEngine;

public class Example : MonoBehaviour { // Attach this to a gameObject that has a renderer. // Copies any property mat has and assigns it to this transform material

Material mat;

void Start() { GetComponent<Renderer> ().material.CopyPropertiesFromMaterial(mat); } }