Get RAPTOR

RaptorLibrary

The material library behind the Materials drawer: provider rows, then user rows from the project settings.

NamespaceAssemblyKindStability
Raptor.EditorToolsRaptor.Editorclasspreview, 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 RaptorLibrary

Fields

ScratchSource

public const string ScratchSource;

Experimental

This member may change in any release.

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.

ParameterTypeDescription
pathstringA path.
folderstringA 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.

ParameterTypeDescription
folderstringA 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.

ParameterTypeDescription
providerIRaptorPackProviderThe 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

This member may change in any release.

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.

ParameterTypeDescription
providerRowsIEnumerable<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.

ParameterTypeDescription
idstringThe 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.