Skip to main content

AltaMenuItem

An abstract class in Alta.MenuItem, the global namespace.

Base for Alta's editor menu commands. Subclasses nest inside an AltaMenuItemBase path class, and editor tooling generates a Unity menu entry for each one. Editor only, does nothing in a running server.

Constructors​

MemberWhat it is
protected AltaMenuItem()Creates an AltaMenuItem with default values.

Properties​

MemberWhat it is
virtual string Description { get; }Optional description for the tool search. Null unless overridden.
string Icon { get; }Always Icons/Command.png.
virtual string Name { get; }Menu entry name. Defaults to the class name with spaces put before each capital letter.
virtual int Priority { get; }Menu ordering priority. Zero unless overridden.
static int SubstringCount { get; }Length of the AltaMenuItemBase type name plus one, cut off the base type name to get the menu path.

Methods​

MemberWhat it is
virtual void Content(TextWriter writer)Writes the body of the generated menu method, which by default just calls the item's run method.
virtual void ExternalContent(TextWriter writer)Writes extra code outside the generated method. Empty by default.
static string GeneratePath(ISearchableTool item)Joins an item's path and cleaned name into the full menu path.
static void GeneratePathSplit(ISearchableTool item, out string path, out string name)Splits an item into menu path and cleaned name, logging an error and stripping %, # and & if the name has them.
string GetArguments()The parameter list written into the generated menu method, always a UnityEditor.MenuCommand.
virtual string GetPath()Menu path, built from the base class's full name with the AltaMenuItemBase prefix removed, _ turned to spaces and + to /.
virtual bool Validate()Whether the menu entry is enabled. True unless overridden.
protected abstract void Run()What the menu item does when picked. Each subclass implements it.
protected void Run<T>()What the menu item does when picked. Each subclass implements it.

Used in​

Members of other types that take, return or hold a AltaMenuItem: