Class HierarchicalBox
Provide a gizmo/handle representing a box where all face can be moved independently. Also add a contained sub gizmo/handle box if contained is used at creation.
상속된 멤버
네임스페이스: UnityEditor.Experimental.Rendering
어셈블리: solution.dll
구문
public class HierarchicalBox
예
class MyComponentEditor : Editor
{
static HierarchicalBox box;
static HierarchicalBox containedBox;
static MyComponentEditor()
{
Color[] handleColors = new Color[]
{
Color.red,
Color.green,
Color.Blue,
new Color(0.5f, 0f, 0f, 1f),
new Color(0f, 0.5f, 0f, 1f),
new Color(0f, 0f, 0.5f, 1f)
};
box = new HierarchicalBox(new Color(1f, 1f, 1f, 0.25), handleColors);
containedBox = new HierarchicalBox(new Color(1f, 0f, 1f, 0.25), handleColors, container: box);
}
[DrawGizmo(GizmoType.Selected|GizmoType.Active)]
void DrawGizmo(MyComponent comp, GizmoType gizmoType)
{
box.center = comp.transform.position;
box.size = comp.transform.scale;
box.DrawHull(gizmoType == GizmoType.Selected);
containedBox.center = comp.innerposition;
containedBox.size = comp.innerScale;
containedBox.DrawHull(gizmoType == GizmoType.Selected);
}
void OnSceneGUI()
{
EditorGUI.BeginChangeCheck();
//container box must be also set for contained box for clamping
box.center = comp.transform.position;
box.size = comp.transform.scale;
box.DrawHandle();
containedBox.DrawHandle();
containedBox.center = comp.innerposition;
containedBox.size = comp.innerScale;
if(EditorGUI.EndChangeCheck())
{
comp.innerposition = containedBox.center;
comp.innersize = containedBox.size;
}
}
}
생성자
이름 | 설명 |
---|---|
HierarchicalBox(Color, Color[], HierarchicalBox) | Constructor. Used to setup colors and also the container if any. |
프로퍼티
이름 | 설명 |
---|---|
baseColor | The baseColor used to fill hull. All other colors are deduced from it except specific handle colors. |
center | The position of the center of the box in Handle.matrix space. |
monoHandle | Allow to switch between the mode where all axis are controlled together or not Note that if there is several handles, they will use the polychrome colors. |
size | The size of the box in Handle.matrix space. |
메서드
이름 | 설명 |
---|---|
DrawHandle() | Draw the manipulable handles |
DrawHull(bool) | Draw the hull which means the boxes without the handles |