お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
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設定された名前から色を取得します
多くのシェーダでは複数の色を使用します。GetColor によりプロパティ名( propertyName
)から色を取得します。
Unityのビルトインシェーダーでは、色を設定するプロパティは4 つあります:
"_Color"
マテリアルのメインカラーとなるプロパティ。 color でもアクセスすることができます。
"_SpecColor"
鏡面の色。specular/glossy/vertexlit のシェーダーで使用できます。
"_Emission"
発光する色。vertexlit のシェーダーで使用できます。
"_ReflectColor"
反射する色。reflective のシェーダーで使用できます。
See Also: color property, SetColor, Shader.PropertyToID.
print (renderer.material.GetColor("_SpecColor"));
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Example() { print(renderer.material.GetColor("_SpecColor")); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def Example() as void: print(renderer.material.GetColor('_SpecColor'))