public float w ;

描述

向量的 w 分量。

using UnityEngine;

// Move and re-size a sphere. // Attach this script to a sphere added to the scene. // Use the x, y and z sliders to change the sphere position and // the w slider to change the scale of the sphere. // // View the changing x, y, z, and z values in the Inspector.

public class ExampleClass : MonoBehaviour { private Vector4 positionAndSize;

void Awake() { positionAndSize = new Vector4(0.0f, 0.0f, 0.0f, 1.0f); }

void Update() { transform.position = (Vector3)positionAndSize;

float a = positionAndSize.w; transform.localScale = new Vector3(a, a, a); }

void OnGUI() { GUI.skin.label.fixedHeight = 40; GUI.skin.label.fontSize = 24;

GUI.Label(new Rect(10, 10, 25, 0), "x:"); positionAndSize.x = GUI.HorizontalSlider(new Rect(60, 20, 200, 10), positionAndSize.x, -1.0f, 1.0f);

GUI.Label(new Rect(10, 50, 25, 0), "y:"); positionAndSize.y = GUI.HorizontalSlider(new Rect(60, 60, 200, 10), positionAndSize.y, -1.0f, 1.0f);

GUI.Label(new Rect(10, 90, 25, 0), "z:"); positionAndSize.z = GUI.HorizontalSlider(new Rect(60, 100, 200, 10), positionAndSize.z, -1.0f, 1.0f);

GUI.Label(new Rect(10, 130, 25, 0), "w:"); positionAndSize.w = GUI.HorizontalSlider(new Rect(60, 140, 200, 10), positionAndSize.w, 0.5f, 2.0f); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961