docs.unity.cn
    Show / Hide Table of Contents

    Interface IUserSetting

    An interface that represents a user setting. Types implementing IUserSetting are eligible for use with UserSettingAttribute, which enables fields to automatically populate the UserSettingsProvider interface.

    Namespace: UnityEditor.SettingsManagement
    Syntax
    public interface IUserSetting

    Properties

    key

    Implement this property to get the key for this value.

    Declaration
    string key { get; }
    Property Value
    Type Description
    String

    The key used to identify the settings entry. This is used along with the type to uniquely identify the value.

    scope

    Implement this property to get the location in the UI where this setting will appear.

    Declaration
    SettingsScope scope { get; }
    Property Value
    Type Description
    SettingsScope

    Indicates whether this is a setting or a preference.

    settings

    Implement this property to get the Settings instance to save and load this setting from.

    Declaration
    Settings settings { get; }
    Property Value
    Type Description
    Settings

    A reference to Settings instance.

    settingsRepositoryName

    Implement this property to get the name of the ISettingsRepository that this setting should be associated with. If null, the first repository matching the scope is used.

    Declaration
    string settingsRepositoryName { get; }
    Property Value
    Type Description
    String

    The bare filename of this repository.

    type

    Implement this property to get the type of the stored value.

    Declaration
    Type type { get; }
    Property Value
    Type Description
    Type

    The type of value. This is used along with the key to uniquely identify the value.

    Methods

    ApplyModifiedProperties()

    Implement this method to explicitly update the ISettingsRepository that is backing this value. 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
    void ApplyModifiedProperties()

    Delete(Boolean)

    Implement this method to delete the saved setting. This does not clear the current value.

    Declaration
    void Delete(bool saveProjectSettingsImmediately = false)
    Parameters
    Type Name Description
    Boolean saveProjectSettingsImmediately

    True to immediately re-serialize project settings. By default, no values are updated.

    See Also
    Reset(Boolean)

    GetDefaultValue()

    Implement this method to return the the default value for this setting.

    Declaration
    object GetDefaultValue()
    Returns
    Type Description
    Object

    The default value for this setting.

    GetValue()

    Implement this method to return the stored settings value. If you are implementing IUserSetting, you should cache this value.

    Declaration
    object GetValue()
    Returns
    Type Description
    Object

    The stored value.

    Reset(Boolean)

    Implement this method to set the current value back to the default.

    Declaration
    void Reset(bool saveProjectSettingsImmediately = false)
    Parameters
    Type Name Description
    Boolean saveProjectSettingsImmediately

    True to immediately re-serialize project settings. By default, no values are updated.

    SetValue(Object, Boolean)

    Implement this method to set the value for this setting.

    Declaration
    void SetValue(object value, bool saveProjectSettingsImmediately = false)
    Parameters
    Type Name Description
    Object value

    The new value.

    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().

    Back to top Copyright © 2021 Unity Technologies
    Generated by DocFX
    on Monday, December 6, 2021
    Terms of use