Handles

class in UnityEditor

Switch to Manual

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 an object 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 objects, 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. This is done by enclosing standard Unity GUI calls in a Handles.BeginGUI and Handles.EndGUI pair within the Editor.OnSceneGUI function. You can use HandleUtility.GUIPointToWorldRay and HandleUtility.WorldToGUIPoint to convert coordinates between 2D GUI and 3D world coordinates.

Static Variables

centerColor用于表示某物体中心的手柄的颜色。
color手柄的颜色。
inverseMatrix所有手柄操作的矩阵的逆矩阵。
lighting手柄是否亮起?
matrix所有手柄操作的矩阵。
preselectionColor用于突出显示鼠标指针下当前未选中的手柄的颜色。
secondaryColor用于一般物体的柔和色。
selectedColor用于当前处于活动状态的手柄的颜色。
xAxisColor用于操纵某物体 X 坐标的手柄的颜色。
yAxisColor用于操纵某物体 Y 坐标的手柄的颜色。
zAxisColor用于操纵某物体 Z 坐标的手柄的颜色。
zTest手柄的 zTest。

Variables

currentCamera为当前摄像机设置视口和相关内容。

Static Functions

ArrowHandleCap绘制一个类似于移动工具所用箭头的箭头。
BeginGUI在 3D 手柄 GUI 内开始一个 2D GUI 块。
Button创建一个 3D 按钮。
CircleHandleCap绘制一个圆形手柄。将此手柄传递给 handle 函数。
ClearCamera清除摄像机。
ConeHandleCap绘制一个锥体手柄。将此手柄传递给 handle 函数。
CubeHandleCap绘制一个立方体手柄。将此手柄传递给 handle 函数。
CylinderHandleCap绘制一个圆柱体手柄。将此手柄传递给 handle 函数。
Disc创建一个可使用鼠标拖动的 3D 圆盘。
DotHandleCap绘制一个圆点手柄。将此手柄传递给 handle 函数。
DrawAAConvexPolygon绘制使用点数组指定的抗锯齿凸多边形。
DrawAAPolyLine绘制使用点数组和宽度指定的抗锯齿线。
DrawBezier绘制通过给定切线的起点和终点的纹理化贝塞尔曲线。
DrawCamera在矩形内绘制一个摄像机。
DrawDottedLine绘制一条从 p1 到 p2 的虚线。
DrawDottedLines绘制一系列虚线段。
DrawGizmosDraw a subset of Gizmos (before or after postprocessing) for the given camera.
DrawLine绘制一条从 p1 到 p2 的线。
DrawLines绘制一系列线段。
DrawPolyLine绘制一条穿过 points 列表的线。
DrawSelectionFrame绘制一个面向选择框的摄像机。
DrawSolidArc在 3D 空间中绘制一个圆扇形(饼图)。
DrawSolidDisc在 3D 空间中绘制一个实心平面圆盘。
DrawSolidRectangleWithOutline在 3D 空间中绘制一个实心轮廓矩形。
DrawWireArc在 3D 空间中绘制一个圆弧。
DrawWireCube使用 center 和 size 绘制一个线框盒体。
DrawWireDisc在 3D 空间中绘制一个平面圆盘的轮廓。
EndGUI结束一个 2D GUI 块并返回到 3D 手柄 GUI。
FreeMoveHandle创建一个不受约束的移动手柄。
FreeRotateHandle创建一个不受约束的旋转手柄。
GetMainGameViewSize获取主游戏视图的宽度和高度。
Label在 3D 空间中创建一个文本标签。
MakeBezierPoints返回表示贝塞尔曲线的点数组。
PositionHandle创建一个位置手柄。
RadiusHandle创建一个场景视图半径手柄。
RectangleHandleCap绘制一个矩形手柄。将此手柄传递给 handle 函数。
RotationHandle创建一个场景视图旋转手柄。
ScaleHandle创建一个场景视图缩放手柄。
ScaleSlider创建一个定向缩放滑动条。
ScaleValueHandle创建一个缩放单个浮点的 3D 手柄。
SetCamera设置当前摄像机,以便所有手柄和辅助图标均使用相应设置进行绘制。
Slider创建一个沿着一个轴移动的 3D 滑动条。
Slider2D创建一个沿两个轴定义的平面移动的 3D 滑动条。
SnapValue将值“val”四舍五入到“snap”的最接近倍数(snap 只能是正数)。
SphereHandleCap绘制一个球体手柄。将此手柄传递给 handle 函数。

Delegates

CapFunction用于绘制手柄的函数,如 Handles.RectangleCap。
SizeFunction用于根据手柄的当前位置获取手柄大小的委托类型。