描述

Vector2 转换为 Vector4

Vector2 可隐式转换 Vector4。(zw 在结果中设置为零)。

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