Class CinemachineTool
This is a generic Tool class for Cinemachine tools. To create a new tool, inherit from CinemachineTool and implement GetIcon(). Your new tool will need to have the [EditorTool("tool-name", typeof(CinemachineVirtualCameraBase))] attribute.
A tool will be drawn iff it has been registered using CinemachineSceneToolUtility.RegisterTool. This is generally done in the OnEnable function of the editor script of the cinemachine component (CinemachineVirtualCamera, CinemachineComponentBase), for which the tool was meant. To unregister, call CinemachineSceneToolUtility.UnregisterTool in the same script's OnDisable function.
To draw the handles related to the tool, you need to implement your drawing function and call it in the editor script's OnSceneGUI function. An alternative for drawing handles is to override this function's OnToolGUI or OnDrawHandles functions (see EditorTool or IDrawSelectedHandles docs for more information).
To check, if a tool has been enabled/disabled in the editor script, use CinemachineSceneToolUtility.IsToolActive.
Implements
Inherited Members
Namespace: Unity.Cinemachine.Editor
Assembly: Unity.Cinemachine.Editor.dll
Syntax
public abstract class CinemachineTool : EditorTool, IDrawSelectedHandles
Properties
toolbarIcon
This lets the editor find the icon of the tool.
Declaration
public override GUIContent toolbarIcon { get; }
Property Value
Type | Description |
---|---|
GUIContent |
Overrides
Methods
GetIcon()
Implement this to set your Tool's icon and tooltip.
Declaration
protected abstract GUIContent GetIcon()
Returns
Type | Description |
---|---|
GUIContent | A GUIContent with an icon set. |
IsAvailable()
This checks whether this tool should be displayed or not.
Declaration
public override bool IsAvailable()
Returns
Type | Description |
---|---|
bool | True, when this tool is to be drawn. False, otherwise. |
Overrides
OnActivated()
This is called when the Tool is selected in the editor.
Declaration
public override void OnActivated()
Overrides
OnDrawHandles()
Implement IDrawSelectedHandles to draw gizmos for this tool even if it is not the active tool.
Declaration
public void OnDrawHandles()
OnWillBeDeactivated()
This is called when the Tool is deselected in the editor.
Declaration
public override void OnWillBeDeactivated()