docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class EditorUtils

    Utility methods for use in Editor code.

    Inheritance
    object
    EditorUtils
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.XR.CoreUtils.Editor
    Assembly: Unity.XR.CoreUtils.Editor.dll
    Syntax
    public static class EditorUtils

    Methods

    GetAssetPreview(Object, Action<Texture>)

    Tries to get an AssetPreview for an asset.

    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 becomes available.

    Returns
    Type Description
    IEnumerator

    An enumerator used to tick the coroutine.

    Remarks

    If a preview is not immediately available, this function waits until IsLoadingAssetPreview(int) changes to false. If the preview has still not loaded, the function uses GetMiniThumbnail(Object) instead.

    GetFieldInfoFromProperty(SerializedProperty)

    Gets the FieldInfo of a SerializedProperty.

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

    The property to get information about.

    Returns
    Type Description
    FieldInfo

    Attributes and metadata about the field.

    GetMemberAttributes(SerializedProperty)

    Gets the attributes of a SerializedProperty.

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

    The property with attributes to enumerate.

    Returns
    Type Description
    Attribute[]

    An array of attributes.

    GetMemberInfoFromPropertyPath(Type, string, out Type)

    Gets 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 declaring type.

    string path

    The property path relative to the declaring type. See propertyPath.

    Type type

    Assigned the Type of the property.

    Returns
    Type Description
    MemberInfo

    Attributes and metadata about the member identified by host and path.

    MaskField(Rect, GUIContent, int, string[], Type)

    Makes an Editor GUI control for mask properties.

    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.

    int 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
    int

    The value modified by the user.

    Remarks

    This function is similar to EditorGUI.MaskField(Rect, string, int, string[]), but 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.

    NicifySerializedPropertyType(string)

    Cleans up a string received 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.

    Remarks

    Strips PPtr<> and $ from a string. Use this function when getting a System.Type using SerializedProperty.type.

    SerializedPropertyToField(SerializedProperty)

    Gets the FieldInfo for a given property.

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

    The property to get information about.

    Returns
    Type Description
    FieldInfo

    The FieldInfo.

    SerializedPropertyToType(SerializedProperty)

    Gets the Type of a SerializedProperty object, if possible.

    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.

    Remarks

    Guesses the type of a SerializedProperty and returns a System.Type, if one exists. This function checks the type of the target object by iterating through its fields looking for one that matches the property name. This may return null if property is a SerializedProperty that represents a native type with no managed equivalent.

    TypeNameToType(string)

    Gets the Type corresponding to the specified name string.

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

    Weak type name

    Returns
    Type Description
    Type

    The best guess for the System.Type of name.

    Remarks

    Searches through all assemblies in the current AppDomain for a class that is assignable to UnityObject and matches the given weak name.

    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)