言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Material.CopyPropertiesFromMaterial

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public function CopyPropertiesFromMaterial(mat: Material): void;
public void CopyPropertiesFromMaterial(Material mat);
public def CopyPropertiesFromMaterial(mat as Material) as void

Description

マテリアルのプロパティを他のマテリアルにコピーします

	// Attach this to a gameObject that has a renderer.
	// 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);
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Material mat;
    void Example() {
        if (!mat) {
            Debug.LogError("Assign a material on the inspector.");
            return;
        }
        renderer.material.CopyPropertiesFromMaterial(mat);
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public mat as Material

	def Example() as void:
		if not mat:
			Debug.LogError('Assign a material on the inspector.')
			return
		renderer.material.CopyPropertiesFromMaterial(mat)