RaptorMaterialsDrawer
Extension points for the Materials drawer.
| Namespace | Assembly | Kind | Stability |
|---|---|---|---|
Raptor.EditorTools | Raptor.Editor | class | preview, since 0.1.0 |
A module can add:
- Per-drawer behaviour:
RegisterExtension. - Labels and groups for hotspot sheets, and an unsaved-work dot on the Materials tab:
RegisterComboChipLabel,RegisterSheetGroup,RegisterUnsavedWork. - Extra drawer width while it needs room:
RegisterWidthProvider,NotifyLayoutChanged.
Registrations are keyed by id, so registering again from an [InitializeOnLoad] constructor on every domain reload is safe. Registrations are read when used, so an extension registered while a drawer is open applies from that drawer's next GUI event. With nothing registered, the drawer is a plain tile grid, combo chips read "SET n", sheets outside the library are grouped under "Other", and the drawer keeps its own width.
public static class RaptorMaterialsDrawerProperties
Epoch
public static int Epoch { get; }Changes whenever an extension is registered or removed.
ExtensionIds
public static IReadOnlyList<string> ExtensionIds { get; }The registered extension ids, in registration order.
Methods
HasUnsavedWork
public static bool HasUnsavedWork()Whether any RegisterUnsavedWork provider reports unsaved work.
Returns: True when any provider reports unsaved work.
NotifyLayoutChanged
public static void NotifyLayoutChanged()Lays out the drawer again in every open RAPTOR window. Call it when a width provider's width changes.
RegisterComboChipLabel
public static void RegisterComboChipLabel(string id, Func<Material, string> label, Func<Material, bool> showsChip = null)Sets the chip label on a combo sheet's tile. A combo master is a single tile that arms a whole set of sheets. The first provider that returns a non-null label wins. With none, the chip reads "SET n", where n counts the master and its members. A combo master whose members are all tiling copies of the sheet has no chip unless showsChip returns true for it.
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | The provider's stable id. | |
label | Func<Material, string> | Returns the chip label, or null to skip this material. | |
showsChip | Func<Material, bool> | null | Returns true to show the chip. When null, the chip shows whenever there is a label. |
Call from an [InitializeOnLoad] static constructor on the main thread. A callback that throws is logged and does not stop the others.
RegisterExtension
public static void RegisterExtension(string id, Func<IRaptorMaterialsDock, IRaptorDockExtension> factory)Registers a per-drawer extension. factory is called once per drawer, on its first GUI event, tile click or menu, and may return null to skip that drawer. Registering an existing id replaces the factory and keeps instances already created.
| Parameter | Type | Description |
|---|---|---|
id | string | The extension's stable id. |
factory | Func<IRaptorMaterialsDock, IRaptorDockExtension> | Creates the drawer's instance. |
Call from an [InitializeOnLoad] static constructor on the main thread. A callback that throws is logged and does not stop the others.
RegisterSheetGroup
public static void RegisterSheetGroup(string id, Func<string, string> group)Groups hotspot sheets that are not in the library, by material path, in the drawer's Hotspot section. The first provider that returns a non-null group wins. With none, the group is "Other".
| Parameter | Type | Description |
|---|---|---|
id | string | The provider's stable id. |
group | Func<string, string> | Returns the group name, or null to skip this sheet. |
Call from an [InitializeOnLoad] static constructor on the main thread. A callback that throws is logged and does not stop the others.
RegisterUnsavedWork
public static void RegisterUnsavedWork(string id, Func<bool> unsaved)Reports unsaved work that outlives a single drawer, such as kept edits. The Materials tab shows a dot while any provider returns true.
| Parameter | Type | Description |
|---|---|---|
id | string | The provider's stable id. |
unsaved | Func<bool> | Returns true while there is unsaved work. |
Call from an [InitializeOnLoad] static constructor on the main thread. A callback that throws is logged and does not stop the others.
RegisterWidthProvider
public static void RegisterWidthProvider(string id, Func<float, float, float> width, Func<bool> widening = null)Widens the Materials drawer while an extension needs room. width receives the drawer's own width and the window's width, and returns the width to use. A provider is widening while widening returns true or, when widening is null, while its width is greater than the drawer's own. The first widening provider sets the width, and the drawer's resize grip is disabled meanwhile. Call NotifyLayoutChanged when the width changes.
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | The provider's stable id. | |
width | Func<float, float, float> | Receives the drawer's and the window's width, and returns the width to use. | |
widening | Func<bool> | null | Returns true while the provider widens the drawer. |
Call from an [InitializeOnLoad] static constructor on the main thread. A callback that throws is logged and does not stop the others.
Reveal
public static bool Reveal<T>(EditorWindow suite, Func<T, bool> act) where T : class, IRaptorDockExtensionShows the Materials panel of the RAPTOR window suite, opening the drawer or showing the docked panel, then runs act on that drawer's T extension and repaints.
| Parameter | Type | Description |
|---|---|---|
suite | EditorWindow | The RAPTOR window. |
act | Func<T, bool> | The action to run on the extension. |
Returns: False when there is no window, panel or extension, or act returned false.
Scratch
public static IDisposable Scratch()Experimental
Clears every registry until the returned scope is disposed, then restores what was registered before. Intended for tests and dry runs. Scopes nest. Drawers apply both changes on their next use.
Returns: A scope. Dispose it to restore the registries.
UnregisterExtension
public static bool UnregisterExtension(string id)Removes an extension. Each drawer disposes of its instance on its next use.
| Parameter | Type | Description |
|---|---|---|
id | string | The extension's stable id. |
Returns: False when there is no such id.
Events
LayoutChanged
public static event Action LayoutChanged;Raised by NotifyLayoutChanged. Open RAPTOR windows lay out their drawer again.
Related types
- IRaptorDockExtension: A per-drawer extension of the Materials drawer (RaptorMaterialsDrawer.RegisterExtension).
- IRaptorMaterialsDock: The Materials drawer instance that hosts an extension, one per open drawer or dock.