docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface ISettingsRepository

    An interface that represents a settings repository, which is responsible for implementing the saving and loading of values.

    Namespace: UnityEditor.SettingsManagement
    Assembly: Unity.Settings.Editor.dll
    Syntax
    public interface ISettingsRepository

    Properties

    name

    Implement this property to get the name to identify this repository.

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

    The bare filename of this repository.

    path

    Implement this property to get the file path to the serialized settings data.

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

    Full path to the JSON file containing the settings data.

    scope

    Implement this property to get the SettingsScope this repository applies to.

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

    Indicates whether this is a Project setting or a User preference.

    Methods

    ContainsKey<T>(string)

    Implement this method to evaluate whether the repository contains a settings entry that matches the specified key and is of type T.

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

    Get<T>(string, T)

    Implement this method to get a value for a settings entry with a matching key and type T.

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

    Remove<T>(string)

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

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

    Save()

    Implement this method to save all settings to their serialized state.

    Declaration
    void Save()

    Set<T>(string, T)

    Implement this method to set a value for a settings entry with a matching key and type T.

    Declaration
    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. Must be serializable.

    Type Parameters
    Name Description
    T

    The type of value that this key points to.

    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)