Class ProjectSettingsRepository
A settings repository that stores data to a JSON file.
Inheritance
Namespace: UnityEditor.SettingsManagement
Syntax
[Serializable]
public class ProjectSettingsRepository : ISettingsRepository
Constructors
ProjectSettingsRepository(String)
Constructor sets the serialized data path.
Declaration
public ProjectSettingsRepository(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path to which settings will be saved in JSON format. |
Properties
path
Declaration
public string path { get; }
Property Value
Type | Description |
---|---|
System.String | File path to the serialized settings data. |
Implements
scope
Declaration
public SettingsScope scope { get; }
Property Value
Type | Description |
---|---|
SettingsScope | This repository implementation is relevant to the Project scope. |
Implements
Methods
ContainsKey<T>(String)
Does the repository contain a setting with key and type.
Declaration
public bool ContainsKey<T>(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The settings key. |
Returns
Type | Description |
---|---|
System.Boolean | True if a setting matching both key and type is found, false if no entry is found. |
Type Parameters
Name | Description |
---|---|
T | The type of value to search for. |
Implements
Get<T>(String, T)
Get a value with key of type T, or return the fallback value if no matching key is found.
Declaration
public T Get<T>(string key, T fallback = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The settings key. |
T | fallback | If no key with a value of type T is found, this value is returned. |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | Type of value to search for. |
Implements
Remove<T>(String)
Remove a key value pair from the settings repository.
Declaration
public void Remove<T>(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key |
Type Parameters
Name | Description |
---|---|
T |
Implements
Save()
Save all settings to their serialized state.
Declaration
public void Save()
Implements
Set<T>(String, T)
Set a value for key of type T.
Declaration
public void Set<T>(string key, T value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The settings key. |
T | value | The value to set. Must be serializable. |
Type Parameters
Name | Description |
---|---|
T | Type of value. |