Vixen
feb85697
csharp
public sealed class EditorMenuAttribute

Puts a verb on a menu, by path — or a line for a command something else registers.

Read the guide page for this →

As a annotation

Valid on
Method, Field

Remarks

Doc 36 § P5, and the smallest thing a project's own editor script can be. One attribute, one static method, no class to derive from and no registration call:

public static class Tools { [EditorMenu("Tools/Rebuild Navigation")] public static void Rebuild() { … } }

Three shapes, and the member decides which. On a static void () method it is a verb: a command, and its line at the end of the path. On a public static string field — a const command id, usually — it is a line for a command something else registers, and every part of the path is a menu: this is how a mode, whose commands are its own because their enablement and their keys are, still declares where those commands appear. On a static IEnumerable<string> () method it is a run of such lines, read once, for a family of ids that are computed rather than written out.

⚠ Read two ways, and both must agree. A plugin off a disk and a project's Editor/ scripts are scanned when the editor loads them — one discrete assembly it has just loaded, which is why the scan is bounded and ADR-002 permits it. An in-tree module is not scanned at all: Vixen.Editor.Plugin.Generator writes its Declared.Register(PluginContext) at compile time and the module's Activate calls it. Both hand what they found to DeclaredMenus, so placement is decided in one place.

⚠ A path, not a menu object. "Tools/My Thing/Do It" creates whatever of it does not exist and joins whatever does — no parent lookup, no ordering call, no menu the author has to find first. Menus compose because nobody owns the tree, which is the one thing about Unity's menu API worth copying wholesale. A submenu that needs a localised title or a place among its siblings is declared with EditorSubmenuAttribute.

Fields and properties (6)

  • public string Path

    Where the item goes. Slashes separate levels.

  • public int Priority

    Which of two lines in one menu comes first. Lower is higher up.

  • public string Id

    The command id, or empty to derive one from the path. A verb's only.

  • public string Title

    The verb's title, as the name of a StringId in a declaration class. A verb's only.

  • public Type? Strings

    The declaration class Title is in, when it is not this assembly's.

  • public bool Separator

    Whether a separator goes above this line.

Methods (1)

  • public EditorMenuAttribute(string path)

    Puts a verb on a menu, by path — or a line for a command something else registers.

Used by (7)

  • BlockoutModeVixen.Editor.Blockout
  • DeclaredVixen.Editor.Texturing
  • DeclaredVixen.Editor.Blockout
  • DeclaredVixen.Editor.Water
  • DeclaredContributionsVixen.Editor.App
  • TexturingModuleVixen.Editor.Texturing
  • WaterModuleVixen.Editor.Water