RaptorProjectChanges
The consent gate for project-wide writes.
| Namespace | Assembly | Kind | Stability |
|---|---|---|---|
Raptor.EditorTools | Raptor.Editor | class | preview, 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 RaptorProjectChangesFields
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.
| Parameter | Type | Description |
|---|---|---|
id | string | The 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.
| Parameter | Type | Description |
|---|---|---|
id | string | The change's id. |
Returns: True when consented.
ConsentKey
public static string ConsentKey(string id)Returns the settings key that holds the consent for id.
| Parameter | Type | Description |
|---|---|---|
id | string | The 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.
| Parameter | Type | Description |
|---|---|---|
change | RaptorProjectChange | The 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.
| Parameter | Type | Description |
|---|---|---|
id | string | The 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.
| Parameter | Type | Description |
|---|---|---|
id | string | The 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.
| Parameter | Type | Description |
|---|---|---|
id | string | The change's id. |
Returns: What happened.
IsDeclared
public static bool IsDeclared(string id)Whether a change with this id is declared.
| Parameter | Type | Description |
|---|---|---|
id | string | The 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.
| Parameter | Type | Description |
|---|---|---|
id | string | The 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.
| Parameter | Type | Description |
|---|---|---|
id | string | The change's id. |
Returns: The state.
Undeclare
public static bool Undeclare(string id)Removes the declaration with this id. Its stored consent is kept.
| Parameter | Type | Description |
|---|---|---|
id | string | The 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.
Related types
- RaptorProjectChangeResult: The outcome of RaptorProjectChanges.Apply.
- RaptorProjectChangeState: A declared change's state (RaptorProjectChanges.State).
- RaptorProjectSettings: RAPTOR's per-project settings file and the section registry for Project Settings → RAPTOR.