RaptorLibrary
The material library behind the Materials drawer: provider rows, then user rows from the project settings.
| Namespace | Assembly | Kind | Stability |
|---|---|---|---|
Raptor.EditorTools | Raptor.Editor | class | preview, since 0.1.0 |
A missing or empty pack folder is not an error and gives an empty pack. The rows are built on first use and rebuilt on the next use after a provider registers or unregisters, the user rows change, or Refresh runs.
public static class RaptorLibraryFields
ScratchSource
public const string ScratchSource;Experimental
The RaptorPackEntry.Source value of a row passed to Scratch.
SettingsKey
public const string SettingsKey;The project settings key for the user rows, stored as RaptorPackList JSON.
SettingsSource
public const string SettingsSource;The RaptorPackEntry.Source value of a user row.
Properties
Entries
public static IReadOnlyList<RaptorPackEntry> Entries { get; }All rows: provider rows in provider order, then user rows. Includes disabled rows (RaptorPackEntry.enabled).
Providers
public static IReadOnlyList<IRaptorPackProvider> Providers { get; }The registered providers, sorted by IRaptorPackProvider.Order and then by id.
UserRows
public static IReadOnlyList<RaptorPackEntry> UserRows { get; }Copies of the user rows stored in the project settings. Their RaptorPackEntry.Source is SettingsSource.
Version
public static int Version { get; }Increments whenever the rows change.
Methods
IsUnder
public static bool IsUnder(string path, string folder)Whether path is folder or inside it.
| Parameter | Type | Description |
|---|---|---|
path | string | A path. |
folder | string | A folder path. |
Returns: True when it is under the folder.
NormaliseFolder
public static string NormaliseFolder(string folder)Trims a folder path and converts it to forward slashes with no trailing slash.
| Parameter | Type | Description |
|---|---|---|
folder | string | A folder path. |
Returns: The normalised path.
Refresh
public static void Refresh()Rereads the providers and the settings. Call it after a provider's rows change.
RegisterProvider
public static void RegisterProvider(IRaptorPackProvider provider)Adds a provider, or replaces the one with the same IRaptorPackProvider.Id. Throws ArgumentNullException when provider is null, and ArgumentException when its id is null or empty.
| Parameter | Type | Description |
|---|---|---|
provider | IRaptorPackProvider | The provider. |
Call from an [InitializeOnLoad] static constructor on the main thread. A callback that throws is logged and does not stop the others.
Scratch
public static Scope Scratch(IEnumerable<RaptorPackEntry> providerRows)Experimental
Replaces every provider's rows with copies of providerRows until the scope is disposed. The copies have ScratchSource as their source. User rows still come from the project settings. To replace those too, use RaptorProjectSettings.Scratch. Scopes nest. Intended for tests and dry runs.
| Parameter | Type | Description |
|---|---|---|
providerRows | IEnumerable<RaptorPackEntry> | The rows to use. |
Returns: A scope. Dispose it to restore the previous rows.
UnregisterProvider
public static bool UnregisterProvider(string id)Removes a provider by id.
| Parameter | Type | Description |
|---|---|---|
id | string | The provider's stable id. |
Returns: True when one was registered.
Events
Changed
public static event Action Changed;Raised after the rows change: when a provider registers or unregisters, the user rows change, a scratch scope opens or closes, or Refresh runs.
Related types
- RaptorLibrary.Scope: A scratch library opened by RaptorLibrary.Scratch.
- RaptorProjectSettings: RAPTOR's per-project settings file and the section registry for Project Settings → RAPTOR.
- IRaptorPackProvider: Adds packs to the material library from code.
- RaptorPackEntry: One row of the material library: a folder of materials shown as a pack in the Materials drawer.