docs.unity3d.com
    Show / Hide Table of Contents

    Class EditorUtils

    Utility methods for use in the Editor

    Inheritance
    Object
    EditorUtils
    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 EditorUtils

    Methods

    GetAssetPreview(Object, Action<Texture>)

    Tries to get an asset preview. If one is not available, waits until IsLoadingAssetPreview is false, and if preview is still not loaded, returns the result of AssetPreview.GetMiniThumbnail

    Declaration
    public static IEnumerator GetAssetPreview(Object asset, Action<Texture> callback)
    Parameters
    Type Name Description
    Object asset

    The asset for which to get a preview

    Action<Texture> callback

    Called with the preview texture as an argument, when it is available

    Returns
    Type Description
    IEnumerator

    An enumerator used to tick the coroutine

    GetFieldInfoFromProperty(SerializedProperty)

    Get the FieldInfo which backs a property

    Declaration
    public static FieldInfo GetFieldInfoFromProperty(SerializedProperty property)
    Parameters
    Type Name Description
    SerializedProperty property

    The property from which to get FieldInfo

    Returns
    Type Description
    FieldInfo

    The FieldInfo which backs the property

    GetMemberAttributes(SerializedProperty)

    Get attributes from the field which represents a property

    Declaration
    public static Attribute[] GetMemberAttributes(SerializedProperty property)
    Parameters
    Type Name Description
    SerializedProperty property

    The property from which to get attributes

    Returns
    Type Description
    Attribute[]

    Array of attributes from property

    GetMemberInfoFromPropertyPath(Type, String, out Type)

    Get MemberInfo for a property by path

    Declaration
    public static MemberInfo GetMemberInfoFromPropertyPath(Type host, string path, out Type type)
    Parameters
    Type Name Description
    Type host

    The type of the container object

    String path

    The property path to search for

    Type type

    The type of the property at path

    Returns
    Type Description
    MemberInfo

    The MemberInfo found on the host type at the given path

    MaskField(Rect, GUIContent, Int32, String[], Type)

    Special version of EditorGUI.MaskField which ensures that only the chosen bits are set. We need this version of the function to check explicitly whether only a single bit was set.

    Declaration
    public static int MaskField(Rect position, GUIContent label, int mask, string[] displayedOptions, Type propertyType)
    Parameters
    Type Name Description
    Rect position

    Rectangle on the screen to use for this control.

    GUIContent label

    Label for the field.

    Int32 mask

    The current mask to display.

    String[] displayedOptions

    A string array containing the labels for each flag.

    Type propertyType

    The type of the property

    Returns
    Type Description
    Int32

    The value modified by the user.

    NicifySerializedPropertyType(String)

    Strip PPtr<> and $ from a string for getting a System.Type from SerializedProperty.type

    Declaration
    public static string NicifySerializedPropertyType(string type)
    Parameters
    Type Name Description
    String type

    Type string

    Returns
    Type Description
    String

    Nicified type string

    SerializedPropertyToField(SerializedProperty)

    Get the FieldInfo for a given property

    Declaration
    public static FieldInfo SerializedPropertyToField(SerializedProperty property)
    Parameters
    Type Name Description
    SerializedProperty property

    The property for which to get the FieldInfo

    Returns
    Type Description
    FieldInfo

    The FieldInfo for the property

    SerializedPropertyToType(SerializedProperty)

    Guess the type of a SerializedProperty and return a System.Type, if one exists. The guess is done by checking the type of the target object and iterating through its fields looking for one that matches the property name. This may return null if you give it a SerializedProperty that represents a native type with no managed equivalent

    Declaration
    public static Type SerializedPropertyToType(SerializedProperty property)
    Parameters
    Type Name Description
    SerializedProperty property

    The SerializedProperty to examine

    Returns
    Type Description
    Type

    The best guess type

    TypeNameToType(String)

    Search through all assemblies in the current AppDomain for a class that is assignable to UnityObject and matches the given weak name TODO: expose internal SerializedProperty.ValidateObjectReferenceValue to remove his hack

    Declaration
    public static Type TypeNameToType(string name)
    Parameters
    Type Name Description
    String name

    Weak type name

    Returns
    Type Description
    Type

    Best guess System.Type

    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