Class ScyllaMenuItemAttribute
Adds a static method to the Scylla menus. Use it instead of Unity's MenuItem
for every item under Tools/Scylla and GameObject/Scylla.
Implements
Inherited Members
Namespace: Scylla.Core.Editor
Assembly: ScyllaCore.Editor.dll
Syntax
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public sealed class ScyllaMenuItemAttribute : Attribute, _Attribute
Remarks
The attribute says where an item belongs, never which priority it has. The Scylla menu registry works out every priority and every divider from the group, the module tier and the order, so an item added by one module cannot move the items of another.
The method must be static and return void. It takes no parameters, or one
MenuCommand whose context is Selection.activeObject. Unlike a
MenuItem, a GameObject item is called once rather
than once per selected object, and its context can be a Project asset. An item that
acts on scene objects reads Selection itself.
[ScyllaMenuItem(ScyllaMenuGroup.Module, "Input/Input Wizard...", ModuleID = ScyllaModuleID.INPUT)]
public static void OpenInputWizard() { }
[ScyllaMenuItem(ScyllaMenuGroup.Module, "Input/Export Bundle...", ModuleID = ScyllaModuleID.INPUT,
Order = 10, DividerBefore = true, Validate = nameof(CanExportBundle))]
public static void ExportBundle() { }
Constructors
ScyllaMenuItemAttribute(ScyllaMenuGroup, string)
Declares a menu item.
Declaration
public ScyllaMenuItemAttribute(ScyllaMenuGroup group, string path)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaMenuGroup | group | The part of the Scylla menus the item belongs to. |
| string | path | The item's path inside its group, with |
Properties
DividerBefore
Gets or sets whether a divider is drawn above the item.
Declaration
public bool DividerBefore { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Ignored for the first item of a submenu. It only applies to items, so it cannot put a divider above a submenu.
Group
Gets the part of the Scylla menus the item belongs to.
Declaration
public ScyllaMenuGroup Group { get; }
Property Value
| Type | Description |
|---|---|
| ScyllaMenuGroup |
ModuleID
Gets or sets the ID of the module the item belongs to, as in ScyllaModuleID.
Declaration
public string ModuleID { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Required for Create, Module
and GameObject items. Create and GameObject items are
grouped by the module's tier, and Core items, which use ScyllaModuleID.CORE,
sort first.
Order
Gets or sets the item's position among its siblings. Lower values come first; items with the same order are sorted by label.
Declaration
public int Order { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Path
Gets the item's path inside its group.
Declaration
public string Path { get; }
Property Value
| Type | Description |
|---|---|
| string |
Section
Gets or sets the section of Assets/Create/Scylla the item's top-level entry
belongs to. Section 0 holds the module submenus; a higher section sorts after it, behind
a divider.
Declaration
public int Section { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Only used by Asset items. The demo content generators use it to sit apart from the module submenus.
A submenu takes the lowest section of the items inside it, so one item with section 0 keeps a submenu in the main block even when its other items use a higher section.
Shortcut
Gets or sets the keyboard shortcut, in Unity's menu shortcut syntax (for example
%#i for Ctrl/Cmd+Shift+I). Empty for none.
Declaration
public string Shortcut { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Validate
Gets or sets the name of a static method on the same type that returns bool
and decides whether the item is enabled. It takes no parameters, or one
MenuCommand.
Declaration
public string Validate { get; set; }
Property Value
| Type | Description |
|---|---|
| string |