docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class InspectorBase<T>

    Base class for defining a custom inspector for values of type T.

    Inheritance
    object
    InspectorBase<T>
    Inspector<T>
    PropertyInspector<TValue>
    PropertyInspector<TValue, TAttribute>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Properties.UI
    Assembly: Unity.Properties.UI.Editor.dll
    Syntax
    public abstract class InspectorBase<T>
    Type Parameters
    Name Description
    T

    The type of the value to inspect.

    Properties

    DisplayName

    Returns the display name of the current value.

    Declaration
    protected string DisplayName { get; }
    Property Value
    Type Description
    string

    IsDelayed

    Returns true if the value field was tagged with the DelayedAttribute.

    Declaration
    protected bool IsDelayed { get; }
    Property Value
    Type Description
    bool

    IsReadOnly

    Returns true if the value field is read-only.

    Declaration
    protected bool IsReadOnly { get; }
    Property Value
    Type Description
    bool

    Name

    Returns the property name of the current value.

    Declaration
    protected string Name { get; }
    Property Value
    Type Description
    string

    Part

    Returns the property path of the current value.

    Declaration
    public PropertyPathPart Part { get; }
    Property Value
    Type Description
    PropertyPathPart

    PropertyPath

    Returns the full property path of the current target.

    Declaration
    public PropertyPath PropertyPath { get; }
    Property Value
    Type Description
    PropertyPath

    Target

    Accessor to the value being inspected.

    Declaration
    protected T Target { get; set; }
    Property Value
    Type Description
    T

    Tooltip

    Returns the tooltip of the current value.

    Declaration
    protected string Tooltip { get; }
    Property Value
    Type Description
    string

    Type

    The type of the declared value type.

    Declaration
    public Type Type { get; }
    Property Value
    Type Description
    Type

    Methods

    Build()

    Called whenever the UI needs to be rebuilt.

    Declaration
    public virtual VisualElement Build()
    Returns
    Type Description
    VisualElement

    The root visual element to use for the inspection.

    DoDefaultGui()

    Generates the default inspector.

    Declaration
    protected VisualElement DoDefaultGui()
    Returns
    Type Description
    VisualElement

    The parent VisualElement containing the generated inspector.

    DoDefaultGui(VisualElement, string)

    Allows to revert to the default drawing handler for a specific field.

    Declaration
    public void DoDefaultGui(VisualElement parent, string propertyPath)
    Parameters
    Type Name Description
    VisualElement parent

    The parent element.

    string propertyPath

    The property path to the field that needs to be drawn.

    DoDefaultGui(VisualElement, PropertyPath)

    Allows to revert to the default drawing handler for a specific property path.

    Declaration
    public void DoDefaultGui(VisualElement parent, PropertyPath propertyPath)
    Parameters
    Type Name Description
    VisualElement parent

    The parent element.

    PropertyPath propertyPath

    The property path to the field that needs to be drawn.

    DoDefaultGuiAtIndex(VisualElement, int)

    Allows to revert to the default drawing handler for a specific field.

    Declaration
    public void DoDefaultGuiAtIndex(VisualElement parent, int index)
    Parameters
    Type Name Description
    VisualElement parent

    The parent element.

    int index

    The index of the field that needs to be drawn.

    DoDefaultGuiAtKey<TKey>(VisualElement, TKey)

    Allows to revert to the default drawing handler for a specific field.

    Declaration
    public void DoDefaultGuiAtKey<TKey>(VisualElement parent, TKey key)
    Parameters
    Type Name Description
    VisualElement parent

    The parent element.

    TKey key

    The key of the field that needs to be drawn.

    Type Parameters
    Name Description
    TKey

    The type of the key.

    GetAttribute<TAttribute>()

    Returns the first attribute of the given type.

    Declaration
    public TAttribute GetAttribute<TAttribute>() where TAttribute : Attribute
    Returns
    Type Description
    TAttribute

    The attribute of the given type for this field.

    Type Parameters
    Name Description
    TAttribute

    The attribute type to get.

    GetAttributes<TAttribute>()

    Returns all attribute of the given type.

    Declaration
    public IEnumerable<TAttribute> GetAttributes<TAttribute>() where TAttribute : Attribute
    Returns
    Type Description
    IEnumerable<TAttribute>

    An IEnumerable<T> for all attributes of the given type.

    Type Parameters
    Name Description
    TAttribute

    The attribute type to get.

    GetContext<TInspectionContext>(string)

    Returns the first inspection context of the given type.

    Declaration
    public TInspectionContext GetContext<TInspectionContext>(string contextName = null) where TInspectionContext : InspectionContext
    Parameters
    Type Name Description
    string contextName

    The name of the inspection context.

    Returns
    Type Description
    TInspectionContext

    The inspection content of the given type, if it exists.

    Type Parameters
    Name Description
    TInspectionContext

    The inspection context type to get.

    HasAttribute<TAttribute>()

    Returns true if the field has any attributes of the given type.

    Declaration
    public bool HasAttribute<TAttribute>() where TAttribute : Attribute
    Returns
    Type Description
    bool

    true if the field has the given attribute type; otherwise, false.

    Type Parameters
    Name Description
    TAttribute

    The attribute type to check for.

    HasContext<TInspectionContext>(string)

    Returns true if an inspection context of the given type exists.

    Declaration
    public bool HasContext<TInspectionContext>(string contextName = null) where TInspectionContext : InspectionContext
    Parameters
    Type Name Description
    string contextName

    The name of the inspection context.

    Returns
    Type Description
    bool

    true, if it exists.

    Type Parameters
    Name Description
    TInspectionContext

    The inspection context type to get.

    IsPathValid(PropertyPath)

    Allows to know if a property exists at the given path.

    Declaration
    public bool IsPathValid(PropertyPath path)
    Parameters
    Type Name Description
    PropertyPath path

    The property path.

    Returns
    Type Description
    bool

    true if a property exists at the given path.

    NotifyChanged()

    Notifies the root element that a change occured on this value. This must be called when doing manual data binding.

    Declaration
    protected void NotifyChanged()
    Remarks

    This is called automatically when the "binding=path" is set to a valid value/field combination.

    Update()

    Called whenever the underlying data changed, so the custom inspector can update it's data.

    Declaration
    public virtual void Update()
    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)