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));

最后修改:2011年1月22日 Saturday 20:46

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。