Interface ISettingsRepository
An interface that represents a settings repository, which is responsible for implementing the saving and loading of values.
Namespace: UnityEditor.SettingsManagement
Syntax
public interface ISettingsRepository
Properties
name
Implement this property to get the name to identify this repository.
Declaration
string name { get; }
Property Value
| Type | Description |
|---|---|
| String | The bare filename of this repository. |
path
Implement this property to get the file path to the serialized settings data.
Declaration
string path { get; }
Property Value
| Type | Description |
|---|---|
| String | Full path to the JSON file containing the settings data. |
scope
Implement this property to get the
Declaration
SettingsScope scope { get; }
Property Value
| Type | Description |
|---|---|
| SettingsScope | Indicates whether this is a |
Methods
ContainsKey<T>(String)
Implement this method to evaluate whether the repository contains a settings entry that matches the specified key and is of type T.
Declaration
bool ContainsKey<T>(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| String | key | The key used to identify the settings entry. |
Returns
| Type | Description |
|---|---|
| Boolean | True if a settings entry matches both |
Type Parameters
| Name | Description |
|---|---|
| T | The type of value that this key points to. |
Get<T>(String, T)
Implement this method to get a value for a settings entry with a matching key and type T.
Declaration
T Get<T>(string key, T fallback = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | key | The key used to identify the settings entry. |
| T | fallback | Specify the value of type |
Returns
| Type | Description |
|---|---|
| T | The value matching both |
Type Parameters
| Name | Description |
|---|---|
| T | The type of value that this key points to. |
Remove<T>(String)
Implement this method to remove a key-value pair from the settings repository. This method identifies the settings entry to remove
by matching the specified key for a value of type T.
Declaration
void Remove<T>(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| String | key | The key used to identify the settings entry. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of value that this key points to. |
Save()
Implement this method to save all settings to their serialized state.
Declaration
void Save()
Set<T>(String, T)
Implement this method to set a value for a settings entry with a matching key and type T.
Declaration
void Set<T>(string key, T value)
Parameters
| Type | Name | Description |
|---|---|---|
| String | key | The key used to identify the settings entry. |
| T | value | The value to set. Must be serializable. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of value that this key points to. |