Class ArrangableElement
Root class for arrangeable UI elements
public abstract class ArrangableElement
- Inheritance
-
ArrangableElement
- Derived
- Inherited Members
- Extension Methods
Constructors
ArrangableElement(LayoutRoot, string)
Creates an arrangable element
public ArrangableElement(LayoutRoot onLayout, string name = "New ArrangableElement")
Parameters
onLayout
LayoutRootThe layout to draw the element on
name
stringThe name of the elemtent
Remarks
Arrangable elements should be placed on the same layout as their parents. This is not a hard requirement, so in theory, it should work to put different parts of the logical tree in different layouts. However, if you do this, know that it may cause unexpected behavior and use with caution.
Properties
ArrangeIsValid
Whether the most recent arrangement can be treated as accurate
public bool ArrangeIsValid { get; }
Property Value
ContentSize
The cached size of this element's actual content. Set from the last result of Measure().
public Vector2 ContentSize { get; }
Property Value
DestroyInProgress
Whether the element is currently in the process of being destroyed
public bool DestroyInProgress { get; }
Property Value
EffectiveSize
The cached effective size in the layout system including padding and visibility. Set from the last result of Measure()
public Vector2 EffectiveSize { get; }
Property Value
HorizontalAlignment
The arrangeable's horizontal alignment
public HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
IsEffectivelyVisible
Whether the element's content will be rendered, i.e. if this elements ancestors in the logical tree are all visible
public bool IsEffectivelyVisible { get; }
Property Value
LayoutRoot
The visual layout parent of this element
public LayoutRoot LayoutRoot { get; }
Property Value
LogicalParent
This element's parent in the layout hierarchy, if any
public ArrangableElement? LogicalParent { get; }
Property Value
MeasureIsResolutionSensitive
Indicates whether an element's ability to accurately measure itself is sensitive to the display resolution. Such elements are automatically remeasured when the resolution changes
public virtual bool MeasureIsResolutionSensitive { get; }
Property Value
MeasureIsValid
Whether the most recent measurement can be treated as accurate
public bool MeasureIsValid { get; }
Property Value
Name
The name of the arrangeable for lookup purposes
public string Name { get; }
Property Value
Padding
The padding around
public Padding Padding { get; set; }
Property Value
PlacementRect
The current rect this element is placed in. This is set before ArrangeOverride(Vector2) is called, so you can access the placement space for custom implementations of the aligned top-left corner if needed
public Rect PlacementRect { get; }
Property Value
VerticalAlignment
The arrangeable's vertical alignment
public VerticalAlignment VerticalAlignment { get; set; }
Property Value
Visibility
The actual visibility of the element
public Visibility Visibility { get; set; }
Property Value
WasEverArranged
Whether the element was successfully arranged at any point
public bool WasEverArranged { get; }
Property Value
Methods
Arrange(Rect)
Positions the object within the allocated space.
public void Arrange(Rect availableSpace)
Parameters
availableSpace
RectThe space available for the element.
ArrangeOverride(Vector2)
Internal implementation to position the object within the allocated space.
protected abstract void ArrangeOverride(Vector2 alignedTopLeftCorner)
Parameters
alignedTopLeftCorner
Vector2The space available for the element.
Destroy()
Destroys this element
public void Destroy()
Remarks
Generally, it assumed when you destroy an element, it, its children, and any underlying UnityEngine.GameObjects are not intended to be reused. Accordingly, a destroyed element will be removed from its parent in most cases and unregistered from the layout system. Attempting to use a destroyed element will result in undefined behavior and may give unwanted results.
DestroyOverride()
Internal implementation to perform any additional cleanup when the element is destroyed
protected abstract void DestroyOverride()
DetachLogicalChild(ArrangableElement)
Detaches a child from this element in the logical tree if this element is its parent.
protected void DetachLogicalChild(ArrangableElement child)
Parameters
child
ArrangableElementThe child object
InvalidateArrange()
Indicates the arrange is no longer valid; will trigger a rearrange of this element and its children.
public void InvalidateArrange()
InvalidateMeasure()
Indicates the measure is no longer valid; will trigger a full re-render of the visual tree.
public void InvalidateMeasure()
Measure()
Calculates the desired size of the object and caches it in ContentSize for later reference in this UI build cycle.
public Vector2 Measure()
Returns
MeasureOverride()
Internal implementation to calculate desired size.
protected abstract Vector2 MeasureOverride()
Returns
SetLogicalChild(ArrangableElement)
Sets the logical parent of the provided child to this element. Usable by any derived arrangable.
protected void SetLogicalChild(ArrangableElement child)
Parameters
child
ArrangableElementThe new child object