Get RAPTOR

RaptorProjectChanges

The consent gate for project-wide writes.

NamespaceAssemblyKindStability
Raptor.EditorToolsRaptor.Editorclasspreview, since 0.1.0

Core features and modules do not write scripting defines, tags, layers, Graphics, Quality, Player or Editor settings, or other ProjectSettings files directly. They Declare the change instead. It runs only when the user has consented (Grant, stored in RaptorProjectSettings) and something requests it (Apply, ApplyConsented, or Apply on the Setup page through GrantAndApply). Declaring, listing and reading consent write nothing.

Consent is stored under the settings key "Consent.<id>" (ConsentKey). A missing key means no consent. Changes are not applied while the editor is playing or entering Play mode. Revoking consent does not undo a change that has already run.

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

public static class RaptorProjectChanges

Fields

ConsentKeyPrefix

public const string ConsentKeyPrefix;

Prefix of the consent keys in the project settings file.

Properties

Declared

public static IReadOnlyList<RaptorProjectChange> Declared { get; }

Gets every declared change, sorted by id.

Methods

Apply

public static RaptorProjectChangeResult Apply(string id)

Runs the declared change once if the project has consented, the change is not in effect yet, and the editor is not playing. An exception from the change is logged and returns RaptorProjectChangeResult.Failed.

ParameterTypeDescription
idstringThe change's id.

Returns: What happened.

ApplyConsented

public static int ApplyConsented()

Applies every declared, consented change that is not in effect yet. Each change runs at most once per domain reload, even if its IsApplied stays false. Does nothing while playing.

Returns: The number applied.

Consented

public static bool Consented(string id)

Whether the project has consented to the change with this id, declared or not.

ParameterTypeDescription
idstringThe change's id.

Returns: True when consented.

ConsentKey

public static string ConsentKey(string id)

Returns the settings key that holds the consent for id.

ParameterTypeDescription
idstringThe change's id.

Returns: The key.

Declare

public static void Declare(RaptorProjectChange change)

Adds a change, or replaces the declaration with the same id. Does not write or run anything.

ParameterTypeDescription
changeRaptorProjectChangeThe declaration.

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

Find

public static RaptorProjectChange Find(string id)

Returns the declared change with this id, or null.

ParameterTypeDescription
idstringThe change's id.

Returns: The change, or null.

Grant

public static void Grant(string id)

Records consent to the change with this id and saves the settings file. Does not run the change; call Apply, or use GrantAndApply instead. Does nothing when consent is already granted.

ParameterTypeDescription
idstringThe change's id.

GrantAndApply

public static RaptorProjectChangeResult GrantAndApply(string id)

Grants consent (Grant) and runs the change (Apply). Used by Apply on the Setup page. While playing, consent is recorded but the change is not run.

ParameterTypeDescription
idstringThe change's id.

Returns: What happened.

IsDeclared

public static bool IsDeclared(string id)

Whether a change with this id is declared.

ParameterTypeDescription
idstringThe change's id.

Returns: True when declared.

Revoke

public static void Revoke(string id)

Withdraws consent for the change with this id and saves the settings file. A change that already ran is not undone. Does nothing when consent was not granted.

ParameterTypeDescription
idstringThe change's id.

State

public static RaptorProjectChangeState State(string id)

Returns the change's state for the Setup page: RaptorProjectChangeState.Applied when it is in effect, whether consented or not, otherwise RaptorProjectChangeState.Granted or RaptorProjectChangeState.Pending.

ParameterTypeDescription
idstringThe change's id.

Returns: The state.

Undeclare

public static bool Undeclare(string id)

Removes the declaration with this id. Its stored consent is kept.

ParameterTypeDescription
idstringThe change's id.

Returns: False when none was declared.

Events

Changed

public static event Action Changed;

Raised after a declaration, consent or applied state changes.