Handles Manual     Reference     Scripting  
Scripting > Editor Classes > Handles
Handles

Various drawing stuff.

Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.

Scene View style 3D GUI controls.

Setting up
You must begin with a call to DrawCamera in order to set up the current camera. All 3d stuff done after DrawCamera uses the camera that was rendered.
Drawing stuff
You can draw 3D gizmo-like stuff. See Also: CubeCap, DrawLine. Set the color of them with Handles.color
Traditional 2D GUI
After having made a call to DrawCamera, you need to wrap traditional GUI calls in a Handles.BeginGUI / EndGUI pair.
Converting coordinate systems
Use HandleUtility.GUIPointToWorldRay and HandleUtility.WorldToGUIPoint to convert coordinates between 2D GUI and 3D world coordinates.

Variables
currentCamera

The camera used for deciding where 3D handles end up

Class Variables
lighting

Are handles lit?

color

Colors of the handles

matrix

Matrix for all handle operations

Class Functions
PositionHandle

Make a 3D Scene view position handle.

RotationHandle

Make a Scene view rotation handle.

ScaleHandle

Make a Scene view scale handle

RadiusHandle

Make a Scene view radius handle

Slider

Make a 3D slider

Slider2D

Slide a handle in a 2D plane

FreeRotateHandle

Make an unconstrained rotation handle.

FreeMoveHandle

Make an unconstrained movement handle.

ScaleSlider

Make a directional scale slider

ScaleValueHandle

Make a single-float draggable handle.

Disc

Make a 3D disc that can be dragged with the mouse

Button

Make a 3D Button.

SnapValue

rounds the value val to the closest multiple of snap (snap can only be posiive)

CubeCap

Draw a cube. Pass this into handle functions.

SphereCap

Draw a Sphere. Pass this into handle functions.

ConeCap

Draw a Cone. Pass this into handle functions.

CylinderCap

Draw a Cylinder. Pass this into handle functions.

RectangleCap

Draw a camera-facing Rectangle. Pass this into handle functions.

SelectionFrame

SimpleSelectionFrame

DotCap

Draw a camera-facing dot. Pass this into handle functions.

CircleCap

Draw a camera-facing Circle. Pass this into handle functions.

ArrowCap

Draw an arrow like those used by the move tool.

DrawLine

Draw a line from p1 to p2.

DrawPolyLine

Draw a line going through the list of all points.

DrawAAPolyLine

Draw anti-aliased line specified with point array and width.

DrawBezier

Draw textured bezier line through start and end points with the given tangents. To get an anti-aliased effect use a texture that is 1x2 pixels with one transparent white pixel and one opaque white pixel. The bezier curve will be swept using this texture.

DrawWireDisc

Draw the outline of a flat disc in 3D space.

DrawWireArc

Draw a circular arc in 3D space.

DrawSolidRectangleWithOutline

Draw a solid outlined rectangle in 3D space.

DrawSolidDisc

Draw a solid flat disc in 3D space.

DrawSolidArc

Draw a circular sector (pie piece) in 3D space.

Label

Make a text label positioned in 3D space.

ClearCamera

Clears the camera.

DrawCamera

Draws a camera inside a rectangle.

SetCamera

Set the current camera so all Handles and Gizmos are draw with its settings.

BeginGUI

Begin a 2D GUI block inside the 3D handle GUI.

EndGUI

End a 2D GUI block and get back to the 3D handle GUI.

Delegates
DrawCapFunction

The function to use for drawing the handle e.g. Handles.RectangleCap.