Material.SetVector 设置向量

function SetVector (propertyName : string, vector : Vector4) : void

Description描述

Set a named vector value.

设置已命名颜色向量值

Four component vectors and colors are the same in Unity shaders. SetVector does exactly the same as SetColor just the input data type is different (xyzw in the vector becomes rgba in the color).

在unity着色器中四维向量和颜色的结果是相同的。SetVector和` SetColor的不同之处在于只是输入的数据类型不同 (xyzw 向量转换成 rgba 颜色)。

参见: SetColor , GetVector .

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		renderer.material.SetVector("_Color", new Vector4(0, 0, 1, 1));
	}
}
renderer.material.SetVector("_Color", Vector4 (0,0,1,1));

Page last updated: 2011-1-22