docs.unity.cn
    Show / Hide Table of Contents

    Class PackageSettingsRepository

    A settings repository that stores data local to a Unity project relative to a package. The settings data is serialized to a JSON file.

    Inheritance
    Object
    FileSettingsRepository
    PackageSettingsRepository
    Inherited Members
    FileSettingsRepository.k_PackageSettingsDirectory
    FileSettingsRepository.k_UserProjectSettingsDirectory
    FileSettingsRepository.scope
    FileSettingsRepository.path
    FileSettingsRepository.name
    FileSettingsRepository.TryLoadSavedJson(String)
    FileSettingsRepository.Save()
    FileSettingsRepository.Set<T>(String, T)
    FileSettingsRepository.Get<T>(String, T)
    FileSettingsRepository.ContainsKey<T>(String)
    FileSettingsRepository.Remove<T>(String)
    Namespace: UnityEditor.SettingsManagement
    Syntax
    public sealed class PackageSettingsRepository : FileSettingsRepository, ISettingsRepository

    Constructors

    PackageSettingsRepository(String, String)

    Initializes and returns an instance of the PackageSettingsRepository with the serialized data location set to a path defined by the specified package and name values relative to the ProjectSettings directory. For example: MyUnityProject/ProjectSettings/Packages/com.example.my-package/Settings.json.

    Declaration
    public PackageSettingsRepository(string package, string name)
    Parameters
    Type Name Description
    String package

    The name of the package to store the serialized data under.

    String name

    The base filename to use for the serialized data location.

    Methods

    GetSettingsPath(String, String)

    Builds and returns a path for a settings file relative to the calling assembly's package directory. This method constructs the location from the specified package and (filename) name under the ProjectSettings folder.

    Declaration
    public static string GetSettingsPath(string packageName, string name = "Settings")
    Parameters
    Type Name Description
    String packageName

    The name of the package requesting this setting.

    String name

    An optional name for the settings file. Default is "Settings."

    Returns
    Type Description
    String

    A package-scoped path to the settings file inside the project's ProjectSettings.

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