docs.unity3d.com
    Show / Hide Table of Contents

    Struct VisualElement.Hierarchy

    Hierarchy is a struct allowing access to the hierarchy of visual elements

    Namespace: UnityEngine.UIElements
    Syntax
    public struct Hierarchy

    Properties

    childCount

    Number of child elements in this object's contentContainer

    Declaration
    public int childCount { get; }
    Property Value
    Type Description
    Int32

    Item[Int32]

    Returns the element at the specified index in the hierarchy

    Declaration
    public VisualElement this[int key] { get; }
    Parameters
    Type Name Description
    Int32 key

    The index of the child

    Property Value
    Type Description
    VisualElement

    The VisualElement at this index

    Remarks

    Throws an exception if the index is invalid.

    parent

    The physical parent of this element in the hierarchy.

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

    Methods

    Add(VisualElement)

    Add an element to this element's contentContainer

    Declaration
    public void Add(VisualElement child)
    Parameters
    Type Name Description
    VisualElement child

    Children()

    Returns the elements from its contentContainer

    Declaration
    public IEnumerable<VisualElement> Children()
    Returns
    Type Description
    IEnumerable<VisualElement>

    Clear()

    Remove all child elements from this element's contentContainer

    Declaration
    public void Clear()

    ElementAt(Int32)

    Retrieves the child element at position

    Declaration
    public VisualElement ElementAt(int index)
    Parameters
    Type Name Description
    Int32 index
    Returns
    Type Description
    VisualElement

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj
    Returns
    Type Description
    Boolean

    Equals(VisualElement.Hierarchy)

    Compares instances of the Hierarchy struct for equality.

    Declaration
    public bool Equals(VisualElement.Hierarchy other)
    Parameters
    Type Name Description
    VisualElement.Hierarchy other

    The structure to compare with.

    Returns
    Type Description
    Boolean

    Returns true if the two instances refer to the same element, false otherwise.

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    IndexOf(VisualElement)

    Retrieves the index of the specified VisualElement in the Hierarchy.

    Declaration
    public int IndexOf(VisualElement element)
    Parameters
    Type Name Description
    VisualElement element

    The element to return the index for.

    Returns
    Type Description
    Int32

    The index of the element, or -1 if the element is not found.

    Insert(Int32, VisualElement)

    Insert an element into this element's contentContainer

    Declaration
    public void Insert(int index, VisualElement child)
    Parameters
    Type Name Description
    Int32 index
    VisualElement child

    Remove(VisualElement)

    Removes this child from the hierarchy

    Declaration
    public void Remove(VisualElement child)
    Parameters
    Type Name Description
    VisualElement child

    RemoveAt(Int32)

    Remove the child element located at this position from this element's contentContainer

    Declaration
    public void RemoveAt(int index)
    Parameters
    Type Name Description
    Int32 index

    Sort(Comparison<VisualElement>)

    Reorders child elements from this VisualElement contentContainer.

    Declaration
    public void Sort(Comparison<VisualElement> comp)
    Parameters
    Type Name Description
    Comparison<VisualElement> comp

    Sorting criteria.

    Operators

    Equality(VisualElement.Hierarchy, VisualElement.Hierarchy)

    Compares instances of the Hierarchy struct for equality.

    Declaration
    public static bool operator ==(VisualElement.Hierarchy x, VisualElement.Hierarchy y)
    Parameters
    Type Name Description
    VisualElement.Hierarchy x

    The left operand of the comparison.

    VisualElement.Hierarchy y

    The right operand of the comparison.

    Returns
    Type Description
    Boolean

    Returns true if the two instances refer to the same element, false otherwise.

    Inequality(VisualElement.Hierarchy, VisualElement.Hierarchy)

    Compares instances of the Hierarchy struct for inequality.

    Declaration
    public static bool operator !=(VisualElement.Hierarchy x, VisualElement.Hierarchy y)
    Parameters
    Type Name Description
    VisualElement.Hierarchy x

    The left operand of the comparison.

    VisualElement.Hierarchy y

    The right operand of the comparison.

    Returns
    Type Description
    Boolean

    Returns false if the two instances refer to the same element, true otherwise.

    In This Article
    • Properties
      • childCount
      • Item[Int32]
      • parent
    • Methods
      • Add(VisualElement)
      • Children()
      • Clear()
      • ElementAt(Int32)
      • Equals(Object)
      • Equals(VisualElement.Hierarchy)
      • GetHashCode()
      • IndexOf(VisualElement)
      • Insert(Int32, VisualElement)
      • Remove(VisualElement)
      • RemoveAt(Int32)
      • Sort(Comparison<VisualElement>)
    • Operators
      • Equality(VisualElement.Hierarchy, VisualElement.Hierarchy)
      • Inequality(VisualElement.Hierarchy, VisualElement.Hierarchy)
    Back to top
    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