docs.unity3d.com
    Show / Hide Table of Contents

    Class EditorPrefsUtils

    Utilities for getting and setting editor preferences that caches the values of those preferences.

    Inheritance
    Object
    EditorPrefsUtils
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.XR.CoreUtils.Editor
    Syntax
    public static class EditorPrefsUtils

    Methods

    ColorToColorPref(String, Color)

    Return a string which matches the format for a color in Editor Prefs

    Declaration
    public static string ColorToColorPref(string path, Color value)
    Parameters
    Type Name Description
    String path

    The preference key/path

    Color value

    The color value

    Returns
    Type Description
    String

    Formatted string representing the color value for Editor Prefs

    GetBool(String, Boolean, String)

    Get the bool value stored in the Editor Preferences for the calling property.

    Declaration
    public static bool GetBool(string typeName, bool defaultValue = false, string propertyName = null)
    Parameters
    Type Name Description
    String typeName

    The name of the type which defines the property

    Boolean defaultValue

    Value to be used as default.

    String propertyName

    Name of calling Property

    Returns
    Type Description
    Boolean

    The bool value stored in the Editor Preferences for the calling property.

    GetColor(String, Color, String)

    Get the color value stored in the Editor Preferences for the calling property.

    Declaration
    public static Color GetColor(string typeName, Color defaultValue, string propertyName = null)
    Parameters
    Type Name Description
    String typeName

    The name of the type which defines the property

    Color defaultValue

    Value to be used as default.

    String propertyName

    Name of calling Property

    Returns
    Type Description
    Color

    The color value stored in the Editor Preferences for the calling property.

    GetFloat(String, Single, String)

    Get the float value stored in the Editor Preferences for the calling property.

    Declaration
    public static float GetFloat(string typeName, float defaultValue = 0F, string propertyName = null)
    Parameters
    Type Name Description
    String typeName

    The name of the type which defines the property

    Single defaultValue

    Value to be used as default.

    String propertyName

    Name of calling Property

    Returns
    Type Description
    Single

    The float value stored in the Editor Preferences for the calling property.

    GetInt(String, Int32, String)

    Get the int value stored in the Editor Preferences for the calling property.

    Declaration
    public static int GetInt(string typeName, int defaultValue = 0, string propertyName = null)
    Parameters
    Type Name Description
    String typeName

    The name of the type which defines the property

    Int32 defaultValue

    Value to be used as default.

    String propertyName

    Name of calling Property

    Returns
    Type Description
    Int32

    The int value stored in the Editor Preferences for the calling property.

    GetPrefKey(String, String)

    Gets the Editor Preference Key by combining the parent object type's full name and the property name

    Declaration
    public static string GetPrefKey(string typeName, string propertyName)
    Parameters
    Type Name Description
    String typeName

    The name of the type which defines the property

    String propertyName

    Name of calling property

    Returns
    Type Description
    String

    Editor Preference Key for property

    GetString(String, String, String)

    Get the string value stored in the Editor Preferences for the calling property.

    Declaration
    public static string GetString(string typeName, string defaultValue = "", string propertyName = null)
    Parameters
    Type Name Description
    String typeName

    The name of the type which defines the property

    String defaultValue

    Value to be used as default.

    String propertyName

    Name of calling Property

    Returns
    Type Description
    String

    The string value stored in the Editor Preferences for the calling property.

    PrefToColor(String)

    Used to get editor preference colors setting

    Declaration
    public static Color PrefToColor(string pref)
    Parameters
    Type Name Description
    String pref

    Name of color preference inf the from of EditorPrefs.GetString("HEADER/PARAMETER")

    Returns
    Type Description
    Color

    Color form Unity Editor Preferences

    SetBool(String, Boolean, String)

    Sets the bool value to the Editor Preferences stored value for the calling property.

    Declaration
    public static void SetBool(string typeName, bool value, string propertyName = null)
    Parameters
    Type Name Description
    String typeName

    The name of the type which defines the property

    Boolean value

    Value to set in Editor Preferences

    String propertyName

    Name of calling Property

    SetColor(String, Color, String)

    Sets the color value to the Editor Preferences stored value for the calling property.

    Declaration
    public static void SetColor(string typeName, Color value, string propertyName = null)
    Parameters
    Type Name Description
    String typeName

    The name of the type which defines the property

    Color value

    Value to set in Editor Preferences

    String propertyName

    Name of calling Property

    SetFloat(String, Single, String)

    Sets the float value to the Editor Preferences stored value for the calling property.

    Declaration
    public static void SetFloat(string typeName, float value, string propertyName = null)
    Parameters
    Type Name Description
    String typeName

    The name of the type which defines the property

    Single value

    Value to set in Editor Preferences

    String propertyName

    Name of calling Property

    SetInt(String, Int32, String)

    Sets the int value to the Editor Preferences stored value for the calling property.

    Declaration
    public static void SetInt(string typeName, int value, string propertyName = null)
    Parameters
    Type Name Description
    String typeName

    The name of the type which defines the property

    Int32 value

    Value to set in Editor Preferences

    String propertyName

    Name of calling Property

    SetString(String, String, String)

    Sets the string value to the Editor Preferences stored value for the calling property.

    Declaration
    public static void SetString(string typeName, string value, string propertyName = null)
    Parameters
    Type Name Description
    String typeName

    The name of the type which defines the property

    String value

    Value to set in Editor Preferences

    String propertyName

    Name of calling Property

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023