W component of the vector.
#pragma strict // 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. private var positionAndSize: Vector4; function Awake() { positionAndSize = new Vector4(0.0f, 0.0f, 0.0f, 1.0f); } function Update() { transform.position = Vector3positionAndSize; var a: float = positionAndSize.w; transform.localScale = new Vector3(a, a, a); } function 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); }
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); } }
Did you find this page useful? Please give it a rating: