RaptorSuiteModelMenuItems
Module rows in the Suite's Model ▾ menu, between "Duplicate as variant" and "Models browser".
| Namespace | Assembly | Kind | Stability |
|---|---|---|---|
Raptor.EditorTools | Raptor.Editor | class | preview, 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 RaptorSuiteModelMenuItemsProperties
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.
| Parameter | Type | Description |
|---|---|---|
item | Item | The row. |
IsRegistered
public static bool IsRegistered(string id)Whether a row with this id is registered.
| Parameter | Type | Description |
|---|---|---|
id | string | The 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | The row's stable id. | |
icon | string | An icon name, or null. | |
label | string | The row's label. | |
open | Action | Runs when the row is selected. | |
order | int | 0 | Lower comes first; ties keep registration order. |
visible | Func<bool> | null | Returns true to list the row; null means always listed. |
drawerNew | bool | false | Whether 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.
Related types
- RaptorSuiteModelMenuItems.Item: One registered row.