Version: 2023.1
언어: 한국어

Handles

class in UnityEditor

매뉴얼로 전환

설명

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.

using UnityEngine;
using UnityEditor;
public class ExampleScript : MonoBehaviour
{
    public float value = 7.0f;
}

// A tiny custom editor for ExampleScript component [CustomEditor(typeof(ExampleScript))] public class ExampleEditor : Editor { // Custom in-scene UI for when ExampleScript // component is selected. public void OnSceneGUI() { var t = target as ExampleScript; var tr = t.transform; var pos = tr.position; // display an orange disc where the object is var color = new Color(1, 0.8f, 0.4f, 1); Handles.color = color; Handles.DrawWireDisc(pos, tr.up, 1.0f); // display object "value" in scene GUI.color = color; Handles.Label(pos, t.value.ToString("F1")); } }

.

정적 변수

centerColorColor to use for handles that represent the center of something.
colorSets the color of handles. Color is a persistent state and affects any handles drawn after it is set. Use DrawingScope to set the color for a block of handles without affecting the color of other handles.
elementColorThe default color of objects in an Edit Mode.
elementPreselectionColorColor to use to highlight an unselected object currently under the mouse pointer in a custom Edit Mode.
elementSelectionColorThe color of selected objects in a Edit Mode.
inverseMatrixThe inverse of the matrix for all handle operations.
lightingAre handles lit?
lineThicknessRetrieves the user preference setting that controls the thickness of tool handle lines. (Read Only)
matrixMatrix for all handle operations. This is used by functions in HandleUtility and Handles to transform controls.
preselectionColorColor to use to highlight an unselected handle currently under the mouse pointer.
secondaryColorSoft color to use for for general things.
selectedColorColor to use for the currently active handle.
UIColliderHandleColorColor to use for the Unity UI's padding visualization.
xAxisColorColor to use for handles that manipulates 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.
zTestzTest of the handles.

변수

currentCameraGets or sets the camera that is currently rendering.

정적 함수

ArrowHandleCapDraw an arrow like those used by the move tool.
BeginGUIBegin a 2D GUI block inside the 3D handle GUI.
ButtonMake a 3D Button.
CircleHandleCapDraw a circle handle. Pass this into handle functions.
ClearCameraClears the camera.
ConeHandleCapDraw a cone handle. Pass this into handle functions.
CubeHandleCapDraw a cube handle. 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.
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.
DrawGizmosDraws a GizmoSubset before or after post-processing for the given camera.
DrawLineDraws a line from p1 to p2.
DrawLinesDraw a list of line segments.
DrawOutlineDraws an outline around the specified GameObjects in the Scene View.
DrawPolyLineDraw a line going through the list of points.
DrawSelectionFrameCreates a square at a position and rotation with a specified size.
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.
DrawTexture3DSDFDraws a 3D texture using Signed Distance Field rendering mode in 3D space.
DrawTexture3DSliceDraws a 3D texture using Slice rendering mode in 3D space.
DrawTexture3DVolumeDraws a 3D texture using Volume rendering mode in 3D space.
DrawWireArcDraws a circular arc in 3D space.
DrawWireCubeDraw a wireframe box with center and size.
DrawWireDiscDraws 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.
LabelCreates a text label for a handle that is positioned in 3D space.
MakeBezierPointsRetuns an array of points to representing the bezier curve.
PositionHandleMake a 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 3D handle that scales a single float.
SetCameraSet the current camera so all Handles and Gizmos are draw with its settings.
ShouldRenderGizmosDetermines whether or not to draw Gizmos.
SliderMake a 3D slider that moves along one axis.
Slider2DMake a 3D slider that moves along a plane defined by two axes.
SnapToGridRounds each Transform.position or Vector3 to the closest multiple of EditorSnapSettings.gridSize.
SnapValueRounds value to the closest multiple of snap if snapping is active. Note that snap can only be positive.
SphereHandleCapDraw a sphere handle. Pass this into handle functions.
TransformHandleCreates a transform handle.

델리게이트

CapFunctionThe function to use for drawing the handle e.g. Handles.RectangleCap.
SizeFunctionA delegate type for getting a handle's size based on its current position.