RaptorProjectSettings
RAPTOR's per-project settings file and the section registry for Project Settings → RAPTOR.
| Namespace | Assembly | Kind | Stability |
|---|---|---|---|
Raptor.EditorTools | Raptor.Editor | class | preview, since 0.1.0 |
Values are stored by key ("Section.Name"). Each getter takes a legacy value, returned when the key is not set. Setters change memory only, and Save writes the file. Loading, reading and opening the settings page do not write. The settings page saves after each edit. The file is in ProjectSettings/ and is not part of the package. Call on the main thread.
public static class RaptorProjectSettingsFields
AssetPath
public const string AssetPath;The settings file path, relative to the project folder.
DataRootKey
public const string DataRootKey;Key of the project's data root. Read by RaptorPaths and ignored while legacy data exists.
FormatVersion
public const int FormatVersion;The file format version written by Save.
Properties
DataRoot
public static string DataRoot { get; }Gets the project's data root setting, or null when not set (RaptorPaths.DataFolder is then used).
FileExists
public static bool FileExists { get; }Whether the settings file exists on disk.
IsDirty
public static bool IsDirty { get; }Whether a value has changed since the file was loaded or last saved.
Keys
public static IReadOnlyList<string> Keys { get; }Gets the stored keys, sorted.
Sections
public static IReadOnlyList<RaptorSettingsSection> Sections { get; }Gets the registered sections in page order (RaptorSettingsSection.Order, then label).
Methods
GetBool
public static bool GetBool(string key, bool legacy)Returns the stored bool, or legacy when the key is not set or cannot be read.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
legacy | bool | What to return when the key is not set. |
Returns: The value.
GetFloat
public static float GetFloat(string key, float legacy)Returns the stored float, or legacy when the key is not set or cannot be read.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
legacy | float | What to return when the key is not set. |
Returns: The value.
GetInt
public static int GetInt(string key, int legacy)Returns the stored int, or legacy when the key is not set or cannot be read.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
legacy | int | What to return when the key is not set. |
Returns: The value.
GetJson
public static T GetJson<T>(string key, T legacy)Returns the stored object (JsonUtility), or legacy when the key is not set or cannot be read.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
legacy | T | What to return when the key is not set. |
Returns: The value.
GetString
public static string GetString(string key, string legacy)Returns the stored string, or legacy when the key is not set.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
legacy | string | What to return when the key is not set. |
Returns: The value.
Has
public static bool Has(string key)Whether key has a stored value.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
Returns: True when stored.
RegisterSection
public static void RegisterSection(RaptorSettingsSection section)Adds a section and its child page to Project Settings → RAPTOR, or replaces the section with the same id.
| Parameter | Type | Description |
|---|---|---|
section | RaptorSettingsSection | The section. |
Call from an [InitializeOnLoad] static constructor on the main thread.
Remove
public static bool Remove(string key)Removes a key. Getters then return the legacy value. Changes memory only; call Save to write the file.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
Returns: True when it was stored.
Save
public static void Save()Writes the settings file (AssetPath) through Unity's ScriptableSingleton API. This is the only method that writes the file. Call it after a deliberate change, such as a user edit or a project setup step.
Scratch
public static Scope Scratch()Experimental
Redirects all getters, setters and Save to an empty in-memory store until the scope is disposed. Nothing is written to disk, and Scope.Saves counts Save calls. Scopes can be nested. Intended for tests and dry runs.
Returns: The scope. Dispose it to restore the previous store.
SetBool
public static void SetBool(string key, bool value)Stores a bool. Changes memory only; call Save to write the file.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
value | bool | The value to store. |
SetFloat
public static void SetFloat(string key, float value)Stores a float. Changes memory only; call Save to write the file.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
value | float | The value to store. |
SetInt
public static void SetInt(string key, int value)Stores an int. Changes memory only; call Save to write the file.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
value | int | The value to store. |
SetJson
public static void SetJson<T>(string key, T value)Stores an object as JsonUtility JSON. Null removes the key. Changes memory only; call Save to write the file.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
value | T | The value to store. |
SetString
public static void SetString(string key, string value)Stores a string. Null removes the key. Changes memory only; call Save to write the file.
| Parameter | Type | Description |
|---|---|---|
key | string | The settings key. |
value | string | The value to store. |
UnregisterSection
public static bool UnregisterSection(string id)Removes the section with this id.
| Parameter | Type | Description |
|---|---|---|
id | string | The section's stable id. |
Returns: False when none was registered.
Events
Changed
public static event Action Changed;Raised after a value is set or removed, or a scratch scope opens or closes.
Related types
- RaptorProjectSettings.Scope: A scratch settings store opened by RaptorProjectSettings.Scratch.
- RaptorSettingsSection: A section of Project Settings → RAPTOR.
- RaptorPaths: Resolves RAPTOR's install and data folders.