docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class UserSettingsRepository

    Represents a settings repository for user preferences.

    Inheritance
    object
    UserSettingsRepository
    Implements
    ISettingsRepository
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEditor.SettingsManagement
    Assembly: Unity.Settings.Editor.dll
    Syntax
    public class UserSettingsRepository : ISettingsRepository

    Properties

    name

    Gets the identifying name for this repository.

    Declaration
    public string name { get; }
    Property Value
    Type Description
    string

    User settings are named "EditorPrefs".

    See Also
    EditorPrefs

    path

    Gets the full path to the file containing the serialized settings data.

    Declaration
    public string path { get; }
    Property Value
    Type Description
    string

    The location stored for this repository.

    Remarks

    This property returns an empty string.

    See Also
    path

    scope

    Gets the scope this repository applies to.

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

    Indicates that this is a User preference.

    See Also
    scope

    Methods

    ContainsKey<T>(string)

    Determines whether this repository contains a settings entry that matches the specified key and is of type T.

    Declaration
    public bool ContainsKey<T>(string key)
    Parameters
    Type Name Description
    string key

    The key used to identify the settings entry.

    Returns
    Type Description
    bool

    True if a settings entry matches both key and type T; false if no entry is found.

    Type Parameters
    Name Description
    T

    The type of value that this key points to.

    See Also
    EditorPrefs

    Get<T>(string, T)

    Returns a value for a settings entry with a matching key and type T.

    Declaration
    public T Get<T>(string key, T fallback = default)
    Parameters
    Type Name Description
    string key

    The key used to identify the settings entry.

    T fallback

    Specify the value of type T to return if the entry can't be found.

    Returns
    Type Description
    T

    The value matching both key and type T. If there was no match, this returns the fallback value.

    Type Parameters
    Name Description
    T

    The type of value that this key points to.

    See Also
    EditorPrefs

    Remove<T>(string)

    Removes a key-value pair from this settings repository. This method identifies the settings entry to remove by matching the specified key for a value of type T.

    Declaration
    public 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.

    See Also
    EditorPrefs

    Save()

    Saves all settings to their serialized state.

    Declaration
    public void Save()
    See Also
    Save()

    Set<T>(string, T)

    Sets a value for a settings entry with a matching key and type T.

    Declaration
    public 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. This must be serializable.

    Type Parameters
    Name Description
    T

    The type of value that this key points to.

    See Also
    EditorPrefs

    Implements

    ISettingsRepository

    See Also

    EditorPrefs
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)