Description

Vector2 转换为 Vector4。

Vector2 可以隐式转换为 Vector4(z 和 w 在结果中设置为零)。


using UnityEngine;
using System.Collections.Generic;

public class ExampleScript : MonoBehaviour { void Start() { Renderer renderer = GetComponent<Renderer>();

// Shader vectors are always defined as Vector4. // The value here is converted to a Vector4 from a Vector2. renderer.material.SetVector("_SomeVariable", Vector2.one); } }