Skip to content

Scene GUI Drawer

Extend HutongGames.Editor.SceneGUIDrawer to implement custom scene tools for actions.

Use SceneGUIAttribute to set the action type the scene GUI is for:

    [SceneGUI(typeof(TransformClampRotation))]
    public class TransformClampRotationSceneGUI : SceneGUIDrawer
    {
        ...
    }

Implement the scene UI in OnSceneGUI:

    public override void OnSceneGUI(SceneView sceneView)
    {
        ...
    }

Override IsValid to return when the scene GUI can be drawn. This defaults to return the result of the target action's CanExecute method. In other words, if CanExecute returns false, the scene GUI is not drawn.

Helper Methods

SceneGUIDrawer provides some helper methods:

HalfSizeHandles()

Call this to draw handles at half their normal size. This can be useful to distinguish action scene handles from normal scene handles.

RestoreHandlesMatrix()

Call this to restore the matrix after calling HalfSizeHandles().

SetColor(Color color)

Call this to set the current Handles.color.

RestoreColor()

Call this to restore the current Handles.color.

Check(params object[] objects)

Call this to check if objects are in a good state to be drawn in the scene GUI.

For example:

    public override bool IsValid => 
        Check(_alignToDirection.Transform, _alignToDirection.Direction);