Class MenuAction
Base class for any action that appears on the ProBuilder toolbar.
Inherited Members
Namespace: UnityEditor.ProBuilder
Assembly: solution.dll
Syntax
public abstract class MenuAction
Constructors
MenuAction()
Creates a new button on the ProBuilder toolbar in the Editor.
Declaration
protected MenuAction()
Fields
onPerformAction
Invoked when the user selects an action to perform from the toolbar.
Declaration
public static Action<MenuAction> onPerformAction
Field Value
| Type | Description |
|---|---|
| Action<MenuAction> |
Properties
enabled
Gets whether or not the action is valid given the current selection.
True if this action is valid with the current selection and mode.
Declaration
public virtual bool enabled { get; }
Property Value
| Type | Description |
|---|---|
| bool |
See Also
group
Gets the category assigned to this action.
Declaration
public abstract ToolbarGroup group { get; }
Property Value
| Type | Description |
|---|---|
| ToolbarGroup |
hasFileMenuEntry
Gets whether this class should have an entry built into the hardware menu. This is not implemented for custom actions.
Declaration
protected virtual bool hasFileMenuEntry { get; }
Property Value
| Type | Description |
|---|---|
| bool |
hidden
Gets whether this action is visible in the ProBuilder toolbar.
True if this action appears in the toolbar with the current mode and settings; false otherwise.
Declaration
public virtual bool hidden { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
This returns false by default.
See Also
icon
Gets the icon to display in the Context Menu for this action.
Declaration
public abstract Texture2D icon { get; }
Property Value
| Type | Description |
|---|---|
| Texture2D |
iconMode
Gets or sets whether the Toolbar display mode is set to Icon mode (true) or Text mode (false).
Declaration
protected bool iconMode { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
iconPath
Gets the local path of the icon to display in the Context Menu for this action.
Declaration
public abstract string iconPath { get; }
Property Value
| Type | Description |
|---|---|
| string |
menuActionState
Gets a flag that indicates both the visibility and enabled state of an action to determine whether the current mode and selection is valid for it.
Declaration
public MenuAction.MenuActionState menuActionState { get; }
Property Value
| Type | Description |
|---|---|
| MenuAction.MenuActionState | . |
menuTitle
Gets the override title for this action to display on the toolbar button.
Declaration
public virtual string menuTitle { get; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
If you don't implement this property, toolbar button displays the tooltip title.
optionsMenuState
Gets a flag that indicates whether the action implements extra options. If it does, it must also implement OnSettingsGUI() so that an options indicator appears for this action button.
Declaration
protected virtual MenuAction.MenuActionState optionsMenuState { get; }
Property Value
| Type | Description |
|---|---|
| MenuAction.MenuActionState |
toolbarPriority
Gets the value to optionally influence where this menu item appears in the toolbar. The default value is -1 (no preference).
Declaration
public virtual int toolbarPriority { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
0 is first, 1 is second, -1 is no preference.
tooltip
Gets the contents of the tooltip to display for this menu action.
Declaration
public abstract TooltipContent tooltip { get; }
Property Value
| Type | Description |
|---|---|
| TooltipContent |
validSelectModes
Gets the SelectMode states where this action applies. This drives the hidden property unless you override it.
Declaration
public virtual SelectMode validSelectModes { get; }
Property Value
| Type | Description |
|---|---|
| SelectMode |
Methods
ContentsChanged()
Declaration
protected void ContentsChanged()
CreateSettingsContent()
Replaces OnSettingsGUI for 2023.2 and newer to display settings in a SceneView overlay. Creates a custom settings window for this action. Populate a root visual element in that method with the settings content.
Declaration
public virtual VisualElement CreateSettingsContent()
Returns
| Type | Description |
|---|---|
| VisualElement |
DoAlternateAction()
Performs the action for this menu item when in Text mode.
Declaration
protected virtual void DoAlternateAction()
DoSceneGUI(SceneView)
If extra handles or gizmos are needed during the action execution in the scene, implement them here.
Declaration
public virtual void DoSceneGUI(SceneView sceneView)
Parameters
| Type | Name | Description |
|---|---|---|
| SceneView | sceneView |
OnSettingsDisable()
Called when the settings window is closed.
Declaration
protected virtual void OnSettingsDisable()
OnSettingsEnable()
Called when the settings window is opened.
Declaration
protected virtual void OnSettingsEnable()
OnSettingsGUI()
Implement the extra settings GUI for your action in this method.
Declaration
protected virtual void OnSettingsGUI()
PerformAction()
Performs the action for this menu item. Use PerformActionImplementation() to implement the action. Calling this method triggers the onPerformAction event.
Declaration
public ActionResult PerformAction()
Returns
| Type | Description |
|---|---|
| ActionResult | A new ActionResult with a summary of the state of the action's success. |
Remarks
Any new action classes that derive from this base class must also use the PerformAction method to register
the new action in the Undo call stack.
PerformActionImplementation()
Performs the action for this menu item. Use this method to implement the action and then use PerformAction() to call it.
Declaration
protected abstract ActionResult PerformActionImplementation()
Returns
| Type | Description |
|---|---|
| ActionResult | A new ActionResult with a summary of the state of the action's success. |
PerformAltAction()
Declaration
public void PerformAltAction()
RegisterChangedCallbacks()
Declaration
public virtual void RegisterChangedCallbacks()
UnregisterChangedCallbacks()
Declaration
public virtual void UnregisterChangedCallbacks()
Events
changed
Declaration
public event Action changed
Event Type
| Type | Description |
|---|---|
| Action |