Class MenuAction
Base class for any action that appears on the ProBuilder toolbar.
Inherited Members
Namespace: UnityEditor.ProBuilder
Assembly: Unity.ProBuilder.Editor.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
disabledIcon
Gets the icon to use when the action button on the toolbar is disabled. By default, this function looks for an image named
${icon}_disabled
. Override this function if your disabled icon does not follow that naming convention or location.
Declaration
protected virtual Texture2D disabledIcon { get; }
Property Value
Type | Description |
---|---|
Texture2D |
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 on the toolbar for this action.
Declaration
public abstract Texture2D icon { get; }
Property Value
Type | Description |
---|---|
Texture2D |
Remarks
This property is not used when the Toolbar display mode is set to text.
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 |
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()
DoAlternateAction()
Performs the action for this menu item when in Text mode.
Declaration
protected virtual void DoAlternateAction()
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 |