Class UserSetting<T>
A generic implementation of IUserSetting.
Inheritance
Namespace: UnityEditor.SettingsManagement
Syntax
public class UserSetting<T> : IUserSetting
Type Parameters
Name | Description |
---|---|
T |
Constructors
UserSetting(Settings, String, T, SettingsScope)
Constructor for UserSetting{T} type.
Declaration
public UserSetting(Settings settings, string key, T value, SettingsScope scope = SettingsScope.Project)
Parameters
Type | Name | Description |
---|---|---|
Settings | settings | The Settings instance that this setting should be saved and loaded from. |
System.String | key | The key for this value. |
T | value | The default value for this key. |
SettingsScope | scope | The scope at which to save this setting. |
Properties
defaultValue
Declaration
public T defaultValue { get; }
Property Value
Type | Description |
---|---|
T | The default value for this setting. |
key
Declaration
public string key { get; }
Property Value
Type | Description |
---|---|
System.String | The key for this value. |
Implements
scope
The scope affects which ISettingsRepository the settings instance will save it's data to.
Declaration
public SettingsScope scope { get; }
Property Value
Type | Description |
---|---|
SettingsScope | The scope at which to save this key and value. |
Implements
settings
Declaration
public Settings settings { get; }
Property Value
Type | Description |
---|---|
Settings | The Settings instance that this setting will be read from and saved to. |
Implements
type
Declaration
public Type type { get; }
Property Value
Type | Description |
---|---|
System.Type | The type that this setting represents ({T}). |
Implements
value
Declaration
public T value { get; set; }
Property Value
Type | Description |
---|---|
T | The currently stored value. |
Methods
ApplyModifiedProperties()
When the inspected type is a reference value, it is possible to change properties without affecting the backing setting. ApplyModifiedProperties provides a method to force serialize these changes.
Declaration
public void ApplyModifiedProperties()
Implements
Delete(Boolean)
Delete the saved setting. Does not clear the current value.
Declaration
public void Delete(bool saveProjectSettingsImmediately = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | saveProjectSettingsImmediately | True to immediately re-serialize project settings. |
Implements
GetDefaultValue()
Get a copy of the default value.
Declaration
public object GetDefaultValue()
Returns
Type | Description |
---|---|
System.Object | The default value. |
Implements
GetValue()
Get the currently stored value.
Declaration
public object GetValue()
Returns
Type | Description |
---|---|
System.Object | The value that is currently set. |
Implements
Reset(Boolean)
Set the current value back to the default.
Declaration
public void Reset(bool saveProjectSettingsImmediately = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | saveProjectSettingsImmediately | True to immediately re-serialize project settings. |
Implements
SetValue(T, Boolean)
Set the value for this setting.
Declaration
public void SetValue(T value, bool saveProjectSettingsImmediately = false)
Parameters
Type | Name | Description |
---|---|---|
T | value | The new value. |
System.Boolean | saveProjectSettingsImmediately | True to immediately serialize the ISettingsRepository that is backing this value, or false to postpone. If not serializing immediately, be sure to call Save(). |
SetValue(Object, Boolean)
Set the value for this setting.
Declaration
public void SetValue(object value, bool saveProjectSettingsImmediately = false)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The new value. |
System.Boolean | saveProjectSettingsImmediately | True to immediately serialize the ISettingsRepository that is backing this value, or false to postpone. If not serializing immediately, be sure to call Save(). |
Implements
ToString()
Get a summary of this setting.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string summary of this setting. |
Overrides
Operators
Implicit(UserSetting<T> to T)
Implicit cast to backing type.
Declaration
public static implicit operator T(UserSetting<T> pref)
Parameters
Type | Name | Description |
---|---|---|
UserSetting<T> | pref | The UserSetting{T} to cast to {T}. |
Returns
Type | Description |
---|---|
T | The currently stored value. |