Handles.PositionHandle 位置控制柄

static function PositionHandle (position : Vector3, rotation : Quaternion) : Vector3



Vector3 - the new position. If the user has not performed any operation, it will return the same value as you passed it in postion. Note: Use HandleUtility.GetHandleSize where you might want to have constant screen-sized handles.



Make a 3D Scene view position handle.


This will behave like the built-in move tool in Unity. If you have assigned something to Undo.SetSnapshotTarget, it will work fully with Undo. If you have assigned a non-null value to ignoreRaycastObjects, the center handle will support full raycast placement. To control the orientation of the handle, set Handles.matrix prior to calling this function.


Handles.PositionHandle 控制柄位置

Make the object look always to the position handle.

//Create a position handle that always looks at "lookAtPoint" in LookAtPoint.js
//创建控制柄位置,总是看向lookAtPoint, LookAtPoint.js文件中

@CustomEditor (LookAtPoint)
class PositionHandleJS extends Editor {
	function OnSceneGUI () {
		target.lookAtPoint =
		Handles.PositionHandle (target.lookAtPoint, Quaternion.identity);
		if (GUI.changed)
			EditorUtility.SetDirty (target);

And the Script attached to this handle:


// LookAtPoint.js
// This Script has to be outside of the editor folder.
// Usage: Just Place this script on the object you want to work the handle with.
@script ExecuteInEditMode()

var lookAtPoint = Vector3.zero;

function Update () {
	transform.LookAt (lookAtPoint);
Page last updated: 2011-7-7