Version: 2023.2
言語: 日本語

Material.CopyMatchingPropertiesFromMaterial

マニュアルに切り替える
public void CopyMatchingPropertiesFromMaterial (Material mat);

パラメーター

mat The Material to copy from.

説明

Copies properties, keyword states and settings from mat to this material, but only if they exist in both materials.

This method copies the following properties if they exist in both materials: Serialized material properties. Non-serialized runtime properties in the shaders. Keyword states, if the keywords exist in both shaders. Material settings: Material.doubleSidedGI, Material.enableInstancing, Material.renderQueue and Material.globalIlluminationFlags.

using UnityEngine;

public class Example : MonoBehaviour { // Attach this script to a GameObject that has a renderer. // Copies any property from mat and assigns it to this transform's material, if the property exists in both materials.

Material mat;

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