Material.SetColor 设置颜色

function SetColor (propertyName : string, color : Color) : void


Set a named color value.


Many shaders use more than one color. Use SetColor to change the propertyName color.

许多着色器使用超过一种颜色。使用 SetColor 来更改 propertyName颜色。

Common color names used by Unity's builtin shaders:

"_Color" is the main color of a material. This can also be accessed via color property.
“_Color”是材质的主颜色,也可以通过 color 属性访问。

"_SpecColor" is the specular color of a material (used in specular/glossy/vertexlit shaders).
"_SpecColor"是材质的高光颜色(使用在specular/glossy/vertexlit 着色器上)

"_Emission" is the emissive color of a material (used in vertexlit shaders).

"_ReflectColor" is the reflection color of the material (used in reflective shaders).

参见: color 属性, GetColor .

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Start() {
		renderer.material.shader = Shader.Find(" Glossy");
function Start () {
	// Set glossy shader so that specular color is used
	renderer.material.shader = Shader.Find (" Glossy");
	// Set red specular highlights
	renderer.material.SetColor ("_SpecColor", );
Page last updated: 2011-1-22