Handles.Slider 滑动柄

static function Slider (position : Vector3, direction : Vector3) : Vector3
static function Slider (position : Vector3, direction : Vector3, size : float, drawFunc : DrawCapFunction, snap : float) : Vector3

Parameters参数

Description描述

Make a 3D slider

制作一个3D滑动柄。

This will draw a 3D-draggable handle on the screen. The handle is constrained to sliding along a direction vector in 3D space.

这将会在屏幕上绘制一个可拖动3D滑动柄。该控制柄被约束滑动沿着3D空间的向量方向。

Slider handle in the Scene View.
场景视图中的滑动控制柄

// Simple script that creates a Magenta Slide Handle that
// points to (0,0,0) nomatter where the target GameObject is located.
//创建一个洋红滑动控制柄指向(0,0,0),target物体的位置。
@CustomEditor (Slide)
class SliderHandleJS extends Editor {
	function OnSceneGUI () {
		Handles.color = Color.magenta;
		target.vectorPoint = Handles.Slider (target.vectorPoint,
		Vector3.zero - target.transform.position);
		if (GUI.changed)
			EditorUtility.SetDirty (target);
	}
}

And the script attached to this Handle:

该脚本附加到这个控制柄物体:

// Usage: Place this script on the Game Object you want to use the
// editor-created slide handle.
//放置这个脚本到游戏物体

@script ExecuteInEditMode()

var vectorPoint : Vector3 = Vector3(0,0,0);

function Update() {
	Debug.Log("Looking at: " + vectorPoint);
}
最后修改:2011年7月7日 Thursday 17:28

本脚本参考基于Unity 3.4.1f5

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