Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Handles.RotationHandle

Suggest a change

Success!

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.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function RotationHandle(rotation: Quaternion, position: Vector3): Quaternion;
public static Quaternion RotationHandle(Quaternion rotation, Vector3 position);
public static def RotationHandle(rotation as Quaternion, position as Vector3) as Quaternion

Parameters

rotation Orientation of the handle.
position Center of the handle in 3D space.

Returns

Quaternion The modified rotation

Note: Use HandleUtility.GetHandleSize where you might want to have constant screen-sized handles.

Description

Make a Scene view rotation handle.

This will behave like the built-in rotation tool in Unity. If you have assigned something to Undo.SetSnapshotTarget, it will work fully with Undo.


Rotate the attached object from the Rotation Handle.

	//Create a rotation handle at (0,0,0) and rotate any object that has "RotateAtPoint.js"
	// attached from 0,0,0.
	
	@CustomEditor (RotateAtPoint)
	class RotationHandleJS extends Editor {
		function OnSceneGUI () {
	        target.rot = Handles.RotationHandle (target.rot, Vector3.zero);
	        if (GUI.changed)
	            EditorUtility.SetDirty (target);
	    }
	}

And the script attached to this handle:

	// RotateAtPoint.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.
	// And control the Object's rotation from the handle that appears at 0,0,0 when 
	// This object is selected.
	
	@script ExecuteInEditMode()
	var rot : Quaternion = Quaternion.identity;
	
	function Update () {
		transform.rotation = rot;
	}