Select your preferred scripting language. All code snippets will be displayed in this language.
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Closeposition | The position of the handle. |
rotation | The rotation of the handle. |
size | The size of the handle. |
capFunc | The function to use for drawing the handle (e.g. Handles.RectangleCap). |
snap | The grid size to snap movement to. |
Vector3 The new value modified by the user's interaction with the handle. If the user has not moved the handle, it will return the same value as you passed into the function.
Make an unconstrained movement handle.
This can move freely in all directions. Hold down CMD to snap, CMD-SHIFT to raysnap against colliders in the Scene.
Free Move handle in the Scene View.
Note: Use HandleUtility.GetHandleSize if you want the handle to always remain the same size on the screen.
#pragma strict // Name this script "FreeMoveEditor" @CustomEditor(FreeMove) @CanEditMultipleObjects public class FreeMoveEditor extends Editor { public function OnSceneGUI() { var t: FreeMove = (target as FreeMove); EditorGUI.BeginChangeCheck(); var pos: Vector3 = Handles.FreeMoveHandle(t.lookAtPoint, Quaternion.identity, .5f, new Vector3(.5f, .5f, .5f), Handles.RectangleCap); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Free Move LookAt Point"); t.lookAtPoint = pos; t.Update(); } } }
// Name this script "FreeMoveEditor" using UnityEngine; using UnityEditor;
[CustomEditor(typeof(FreeMove))] [CanEditMultipleObjects] public class FreeMoveEditor : Editor { public void OnSceneGUI() { FreeMove t = (target as FreeMove);
EditorGUI.BeginChangeCheck(); Vector3 pos = Handles.FreeMoveHandle(t.lookAtPoint, Quaternion.identity,.5f,new Vector3(.5f,.5f,.5f),Handles.RectangleCap); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Free Move LookAt Point"); t.lookAtPoint = pos; t.Update(); } } }
And the script attached to this handle:
#pragma strict // Name this script "FreeMove" @ExecuteInEditMode public class FreeMove extends MonoBehaviour { public var lookAtPoint: Vector3 = Vector3.zero; public function Update() { transform.LookAt(lookAtPoint); } }
// Name this script "FreeMove" using UnityEngine;
[ExecuteInEditMode] public class FreeMove : MonoBehaviour { public Vector3 lookAtPoint = Vector3.zero;
public void Update() { transform.LookAt(lookAtPoint); } }