Legacy Documentation: Version 5.5
LanguageEnglish
  • C#
  • JS

Script language

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

Handles

class in UnityEditor

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

Submission failed

For 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.

Close

Cancel

Description

Custom 3D GUI controls and drawing in the Scene view.

Handles are the 3D controls that Unity uses to manipulate items in the Scene view. There are a number of built-in Handle GUIs, such as the familiar tools to position, scale and rotate a GameObject via the Transform component. However, it is also possible to define your own Handle GUIs to use with custom component editors. Such GUIs can be a very useful way to edit procedurally-generated Scene content, "invisible" items and groups of related GameObjects, such as waypoints and location markers.

You can also supplement the 3D Handle GUI in the Scene with 2D buttons and other controls overlaid on the Scene view. Do this by enclosing standard Unity GUI calls in a Handles.BeginGUI / EndGUI pair within the //OnSceneGUI// function. Use HandleUtility.GUIPointToWorldRay and HandleUtility.WorldToGUIPoint to convert coordinates between 2D GUI and 3D world coordinates.

Static Variables

centerColorColor to use for handles that represent the center of something.
colorLook up or set the Color of the handles.
inverseMatrixThe inverse of the matrix for all handle operations.
lightingAre handles lit?
matrixMatrix for all handle operations.
secondaryColorSoft color to use for for less interactive UI, or handles that are used rarely (or not at all).
selectedColorColor to use for the currently active handle.
xAxisColorColor to use for handles that manipulate the X coordinate of something.
yAxisColorColor to use for handles that manipulates the Y coordinate of something.
zAxisColorColor to use for handles that manipulates the Z coordinate of something.

Variables

currentCameraSetup viewport and stuff for a current camera.

Static Functions

ArrowCapDraw an arrow like those used by the move tool.
ArrowHandleCapDraw an arrow like those used by the move tool.
BeginGUIBegin a 2D GUI block inside the 3D handle GUI.
ButtonMake a 3D button.
CircleCapDraw a camera-facing Circle. Pass this into handle functions.
CircleHandleCapDraw a circle handle. Pass this into handle functions.
ClearCameraClears the camera.
ConeCapDraw a Cone. Pass this into handle functions.
ConeHandleCapDraw a cone handle. Pass this into handle functions.
CubeCapDraw a cube. Pass this into handle functions.
CubeHandleCapDraw a cube handle. Pass this into handle functions.
CylinderCapDraw a Cylinder. Pass this into handle functions.
CylinderHandleCapDraw a cylinder handle. Pass this into handle functions.
DiscMake a 3D disc that can be dragged with the mouse.
DotCapDraw a camera-facing dot. Pass this into handle functions.
DotHandleCapDraw a dot handle. Pass this into handle functions.
DrawAAConvexPolygonDraw anti-aliased convex polygon specified with point array.
DrawAAPolyLineDraw anti-aliased line specified with point array and width.
DrawBezierDraw textured bezier line through start and end points with the given tangents.
DrawCameraDraws a camera inside a rectangle.
DrawDottedLineDraw a dotted line from p1 to p2.
DrawDottedLinesDraw a list of dotted line segments.
DrawLineDraw a line from p1 to p2.
DrawLinesDraw a list of line segments.
DrawPolyLineDraw a line going through the list of all points.
DrawSelectionFrameDraw a camera facing selection frame.
DrawSolidArcDraw a circular sector (pie piece) in 3D space.
DrawSolidDiscDraw a solid flat disc in 3D space.
DrawSolidRectangleWithOutlineDraw a solid outlined rectangle in 3D space.
DrawWireArcDraw a circular arc in 3D space.
DrawWireCubeDraw a wireframe box with center and size.
DrawWireDiscDraw the outline of a flat disc in 3D space.
EndGUIEnd a 2D GUI block and get back to the 3D handle GUI.
FreeMoveHandleMake an unconstrained movement handle.
FreeRotateHandleMake an unconstrained rotation handle.
GetMainGameViewSizeGet the width and height of the main Game view.
LabelMake a text label positioned in 3D space.
MakeBezierPointsRetuns an array of points to representing the bezier curve. See Handles.DrawBezier.
PositionHandleMake a 3D Scene view position handle.
RadiusHandleMake a Scene view radius handle.
RectangleHandleCapDraw a rectangle handle. Pass this into handle functions.
RotationHandleMake a Scene view rotation handle.
ScaleHandleMake a Scene view scale handle.
ScaleSliderMake a directional scale slider.
ScaleValueHandleMake a single-float draggable handle.
SelectionFrameDraw a camera facing selection frame.
SetCameraSet the current camera so all Handles and Gizmos are draw with its settings.
SliderMake a 3D slider.
Slider2DSlide a handle in a 2D plane.
SnapValueRounds the value val to the closest multiple of snap (snap can only be positive).
SphereCapDraw a Sphere. Pass this into handle functions.
SphereHandleCapDraw a sphere handle. Pass this into handle functions.

Delegates

CapFunctionThe function to use for drawing the handle e.g. Handles.RectangleCap.
DrawCapFunctionThe function to use for drawing the handle e.g. Handles.RectangleCap.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961