Class ScyllaEditorPrefs
Reads and writes editor preferences under Scylla's key prefix.
Inherited Members
Namespace: Scylla.Core.Editor
Assembly: ScyllaCore.Editor.dll
Syntax
public static class ScyllaEditorPrefs
Remarks
Every key is namespaced with PREFS_PREFIX, so callers pass the suffix only. Doing the prefixing in one place is the point: preferences are global to the editor installation, and a key written without the prefix collides with whatever else happens to use that name.
This exists as a static utility rather than as helpers on a window base class because the callers that most need it are not windows. A control persists its own state and has no access to a window's protected members, which is why ScyllaSplitView could not reuse the previous implementation.
Editor-only, main thread only. UnityEditor.EditorPrefs writes to disk on some platforms, so this is not something to call every frame.
Methods
DeleteKey(string)
Removes a preference, so the next read returns its default.
Declaration
public static void DeleteKey(string keySuffix)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keySuffix | The unprefixed key. |
GetBool(string, bool)
Reads a boolean preference.
Declaration
public static bool GetBool(string keySuffix, bool defaultValue = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keySuffix | The unprefixed key. |
| bool | defaultValue | Value returned when the key is absent. |
Returns
| Type | Description |
|---|---|
| bool | The stored value, or the default. |
GetFloat(string, float)
Reads a float preference.
Declaration
public static float GetFloat(string keySuffix, float defaultValue = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keySuffix | The unprefixed key. |
| float | defaultValue | Value returned when the key is absent. |
Returns
| Type | Description |
|---|---|
| float | The stored value, or the default. |
GetInt(string, int)
Reads an integer preference.
Declaration
public static int GetInt(string keySuffix, int defaultValue = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keySuffix | The unprefixed key. |
| int | defaultValue | Value returned when the key is absent. |
Returns
| Type | Description |
|---|---|
| int | The stored value, or the default. |
GetString(string, string)
Reads a string preference.
Declaration
public static string GetString(string keySuffix, string defaultValue = "")
Parameters
| Type | Name | Description |
|---|---|---|
| string | keySuffix | The unprefixed key. |
| string | defaultValue | Value returned when the key is absent. |
Returns
| Type | Description |
|---|---|
| string | The stored value, or the default. |
HasKey(string)
Reports whether a preference has been written.
Declaration
public static bool HasKey(string keySuffix)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keySuffix | The unprefixed key. |
Returns
| Type | Description |
|---|---|
| bool |
|
Key(string)
Builds the full preference key for a suffix.
Declaration
public static string Key(string keySuffix)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keySuffix | The unprefixed key. |
Returns
| Type | Description |
|---|---|
| string | The namespaced key. |
Remarks
Exposed for the rare caller that needs the literal key, such as one deleting a preference through another API. Ordinary reads and writes should use the typed methods below, which apply this themselves.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when the suffix is |
SetBool(string, bool)
Writes a boolean preference.
Declaration
public static void SetBool(string keySuffix, bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keySuffix | The unprefixed key. |
| bool | value | The value to store. |
SetFloat(string, float)
Writes a float preference.
Declaration
public static void SetFloat(string keySuffix, float value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keySuffix | The unprefixed key. |
| float | value | The value to store. |
SetInt(string, int)
Writes an integer preference.
Declaration
public static void SetInt(string keySuffix, int value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keySuffix | The unprefixed key. |
| int | value | The value to store. |
SetString(string, string)
Writes a string preference.
Declaration
public static void SetString(string keySuffix, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | keySuffix | The unprefixed key. |
| string | value | The value to store. |