Table of Contents

Class ArrangableElement

Namespace
MagicUI.Core
Assembly
MagicUI.dll

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 LayoutRoot

The layout to draw the element on

name string

The 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

bool

ContentSize

The cached size of this element's actual content. Set from the last result of Measure().

public Vector2 ContentSize { get; }

Property Value

Vector2

DestroyInProgress

Whether the element is currently in the process of being destroyed

public bool DestroyInProgress { get; }

Property Value

bool

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

Vector2

HorizontalAlignment

The arrangeable's horizontal alignment

public HorizontalAlignment HorizontalAlignment { get; set; }

Property Value

HorizontalAlignment

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

bool

LayoutRoot

The visual layout parent of this element

public LayoutRoot LayoutRoot { get; }

Property Value

LayoutRoot

LogicalParent

This element's parent in the layout hierarchy, if any

public ArrangableElement? LogicalParent { get; }

Property Value

ArrangableElement

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

bool

MeasureIsValid

Whether the most recent measurement can be treated as accurate

public bool MeasureIsValid { get; }

Property Value

bool

Name

The name of the arrangeable for lookup purposes

public string Name { get; }

Property Value

string

Padding

The padding around

public Padding Padding { get; set; }

Property Value

Padding

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

Rect

VerticalAlignment

The arrangeable's vertical alignment

public VerticalAlignment VerticalAlignment { get; set; }

Property Value

VerticalAlignment

Visibility

The actual visibility of the element

public Visibility Visibility { get; set; }

Property Value

Visibility

WasEverArranged

Whether the element was successfully arranged at any point

public bool WasEverArranged { get; }

Property Value

bool

Methods

Arrange(Rect)

Positions the object within the allocated space.

public void Arrange(Rect availableSpace)

Parameters

availableSpace Rect

The 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 Vector2

The 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 ArrangableElement

The 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

Vector2

MeasureOverride()

Internal implementation to calculate desired size.

protected abstract Vector2 MeasureOverride()

Returns

Vector2

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 ArrangableElement

The new child object