Get RAPTOR

RaptorSuiteModelMenuItems

Module rows in the Suite's Model ▾ menu, between "Duplicate as variant" and "Models browser".

NamespaceAssemblyKindStability
Raptor.EditorToolsRaptor.Editorclasspreview, since 0.1.0

A row can also act as the Models drawer's New button (drawerNew), with the row's label as its tooltip. Rows do not need a model storage provider, so they are listed even when the project's storage refuses model operations. Rows are sorted by order, then registration order.

The first registration of an id wins; a repeat does nothing. A visible check that throws hides its row, and an action that throws is logged. Each failure is logged once per id. Registrations are editor-only and cleared on domain reload, after which registrants run again.

public static class RaptorSuiteModelMenuItems

Properties

Count

public static int Count { get; }

Gets the number of rows.

DrawerNewItem

public static Item DrawerNewItem { get; }

Gets the Models drawer's New row: the first visible row registered with drawerNew, or null when there is none.

Ids

public static IReadOnlyList<string> Ids { get; }

Gets a snapshot of every row id in menu order.

Version

public static int Version { get; }

Gets a counter that increases by one on every change.

Methods

Invoke

public static void Invoke(Item item)

Runs a row's action. An action that throws is logged once per id and not rethrown.

ParameterTypeDescription
itemItemThe row.

IsRegistered

public static bool IsRegistered(string id)

Whether a row with this id is registered.

ParameterTypeDescription
idstringThe row's stable id.

Returns: True when registered.

Register

public static bool Register(string id, string icon, string label, Action open, int order = 0, Func<bool> visible = null, bool drawerNew = false)

Adds a Model ▾ row. When several visible rows set drawerNew, the first in order becomes the New button. Returns false and keeps the existing row when id is already registered. Throws for a blank id or label, or a null action.

ParameterTypeDefaultDescription
idstringThe row's stable id.
iconstringAn icon name, or null.
labelstringThe row's label.
openActionRuns when the row is selected.
orderint0Lower comes first; ties keep registration order.
visibleFunc<bool>nullReturns true to list the row; null means always listed.
drawerNewboolfalseWhether the row is also the Models drawer's New button.

Returns: False when the id is taken.

Call from an [InitializeOnLoad] static constructor on the main thread.

VisibleItems

public static IReadOnlyList<Item> VisibleItems()

Returns the rows currently listed, in order.

Returns: The rows.