docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class UserSettingsRepository

    A settings repository backed by the UnityEditor.EditorPrefs class.

    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

    An identifying name for this repository. User settings are named "EditorPrefs."

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

    path

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

    File path to the serialized settings data.

    Remarks

    This property returns an empty string.

    scope

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

    What SettingsScope this repository applies to.

    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
    string key

    The settings key.

    Returns
    Type Description
    bool

    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.

    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 = default)
    Parameters
    Type Name Description
    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.

    Remove<T>(string)

    Remove a key value pair from the settings repository.

    Declaration
    public void Remove<T>(string key)
    Parameters
    Type Name Description
    string key
    Type Parameters
    Name Description
    T

    Save()

    Save all settings to their serialized state.

    Declaration
    public void Save()

    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
    string key

    The settings key.

    T value

    The value to set. Must be serializable.

    Type Parameters
    Name Description
    T

    Type of value.

    Implements

    ISettingsRepository
    In This Article
    Back to top
    Copyright © 2025 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)