Vixen
02b45cc4
csharp
public sealed class EditorMenuAttribute

Puts a static method on a menu, by path.

No guide page documents this yet — the page shows what the code says about itself.

As a annotation

Valid on
Method

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() { … } }

⚠ Read only from a project's Editor/ assembly, and nowhere else. Finding these means enumerating an assembly's types, which ADR-002 forbids as a way of building the editor — a scan reads metadata a trimmed publish has deleted and makes start-up cost grow with what is installed. Neither applies here: the assembly is one the editor compiled seconds ago from a folder it is watching, it is a dozen types, and there is no publish. A plugin shipped as a built assembly uses IEditorPlugin, where the registration is a call the author writes and the generator has a chance to help.

⚠ A path, not a menu object. "Tools/My Thing/Do It" creates whatever of it does not exist — no parent lookup, no ordering call, no menu the script has to find first. Menus compose because nobody owns the tree, which is the one thing about Unity's menu API worth copying wholesale.

Fields and properties (3)

  • public string Path

    Where the item goes. Slashes separate levels; the last part is the line itself.

  • 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.

Methods (1)

  • public EditorMenuAttribute(string path)

    Puts a static method on a menu, by path.

Used by (1)

  • DeclaredContributionsVixen.Editor.App