Get RAPTOR

RaptorProjectSettings

RAPTOR's per-project settings file and the section registry for Project Settings → RAPTOR.

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

Fields

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.

ParameterTypeDescription
keystringThe settings key.
legacyboolWhat 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.

ParameterTypeDescription
keystringThe settings key.
legacyfloatWhat 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.

ParameterTypeDescription
keystringThe settings key.
legacyintWhat 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.

ParameterTypeDescription
keystringThe settings key.
legacyTWhat 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.

ParameterTypeDescription
keystringThe settings key.
legacystringWhat to return when the key is not set.

Returns: The value.

Has

public static bool Has(string key)

Whether key has a stored value.

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

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

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

This member may change in any release.

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.

ParameterTypeDescription
keystringThe settings key.
valueboolThe value to store.

SetFloat

public static void SetFloat(string key, float value)

Stores a float. Changes memory only; call Save to write the file.

ParameterTypeDescription
keystringThe settings key.
valuefloatThe value to store.

SetInt

public static void SetInt(string key, int value)

Stores an int. Changes memory only; call Save to write the file.

ParameterTypeDescription
keystringThe settings key.
valueintThe 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.

ParameterTypeDescription
keystringThe settings key.
valueTThe 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.

ParameterTypeDescription
keystringThe settings key.
valuestringThe value to store.

UnregisterSection

public static bool UnregisterSection(string id)

Removes the section with this id.

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