Class ScyllaUIStackBase
Abstract base class for Scylla UI stack containers (ScyllaUIHStack
and ScyllaUIVStack). Encapsulates shared properties, child snapshot
management, dirty-batching, and the upward UnityEngine.UI.ILayoutElement interop
used to compose Scylla stacks inside native uGUI containers like
ScrollRect.
Inheritance
Implements
Inherited Members
Namespace: Scylla.Core.Util.UI
Assembly: ScyllaCore.dll
Syntax
[DisallowMultipleComponent]
[RequireComponent(typeof(RectTransform))]
[ExecuteAlways]
public abstract class ScyllaUIStackBase : UIBehaviour, ILayoutElement
Remarks
Children are positioned by the internal Scylla.Core.Util.UI.ScyllaUILayoutSolver; UnityEngine.UI.ILayoutElement is implemented so that native parents see the stack's preferred main-axis size. UnityEngine.UI.ILayoutGroup is deliberately not implemented so Unity's auto-layout system does not recurse into the stack.
Every property setter calls MarkDirty(); the owning
ScyllaUILayoutRoot flushes dirty stacks once per frame in
LateUpdate. A stack without an ancestor root falls back to a per-stack
self-solve in its own LateUpdate.
Properties
Alignment
Main-axis distribution mode. When a Style is assigned, returns the style's resolved alignment for the parent's current aspect ratio; the setter still writes the local field, which is used when no style is assigned.
Declaration
public ScyllaUIAlignment Alignment { get; set; }
Property Value
| Type | Description |
|---|---|
| ScyllaUIAlignment |
CrossAlignment
Cross-axis alignment mode. When a Style is assigned, returns the style's cross alignment; the setter still writes the local field.
Declaration
public ScyllaUICrossAlignment CrossAlignment { get; set; }
Property Value
| Type | Description |
|---|---|
| ScyllaUICrossAlignment |
CrossAxisSizeMode
Sizing mode along the stack's cross axis. Operates identically to MainAxisSizeMode but controls the perpendicular axis.
Declaration
public ScyllaUISizeMode CrossAxisSizeMode { get; set; }
Property Value
| Type | Description |
|---|---|
| ScyllaUISizeMode |
IsGrid
true for track-based 2D grids (ScyllaUIGrid) where the
solver dispatches to a column/row track placement path. Default false.
Declaration
public virtual bool IsGrid { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsHorizontal
true for horizontal stacks (main axis is X), false for vertical
stacks (main axis is Y). Implemented by concrete subclasses. The value is
read on every solve, so adaptive subclasses may return a dynamically computed
orientation.
Declaration
public abstract bool IsHorizontal { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsZStack
true for depth/overlay stacks (ScyllaUIZStack) where
children sit atop each other at the same content origin rather than being
distributed along a main axis. Default false.
Declaration
public virtual bool IsZStack { get; }
Property Value
| Type | Description |
|---|---|
| bool |
MainAxisSizeMode
Sizing mode along the stack's main axis. Determines whether the stack expands to fill the parent (Fill), collapses to its children's aggregate extent (Hug), or leaves the axis size unchanged (Fixed).
Declaration
public ScyllaUISizeMode MainAxisSizeMode { get; set; }
Property Value
| Type | Description |
|---|---|
| ScyllaUISizeMode |
Padding
Per-edge inner padding. When a Style is assigned, returns the style's resolved padding for the parent's current aspect ratio.
Declaration
public ScyllaUIEdgeInsets Padding { get; set; }
Property Value
| Type | Description |
|---|---|
| ScyllaUIEdgeInsets |
RectTransform
Cached RectTransform component reference. Resolved via
GetComponent on first access and cached thereafter. Always valid when
called after Awake because the component attribute
[RequireComponent(typeof(RectTransform))] guarantees its presence.
Declaration
public RectTransform RectTransform { get; }
Property Value
| Type | Description |
|---|---|
| RectTransform |
Spacing
Gap between children along the main axis. When a Style is assigned, returns the style's resolved spacing for the parent's current aspect ratio.
Declaration
public ScyllaUILength Spacing { get; set; }
Property Value
| Type | Description |
|---|---|
| ScyllaUILength |
Style
Optional shared style preset (CSS-class analog). When non-null, the stack reads padding, spacing, and alignment from the style instead of its local serialized fields, and applies any matching breakpoint overrides.
Declaration
public ScyllaUILayoutStyle Style { get; set; }
Property Value
| Type | Description |
|---|---|
| ScyllaUILayoutStyle |
flexibleHeight
Flexible height weight reported to native uGUI containers. Returns -1,
indicating the stack does not participate in flexible height distribution in the
native layout system.
Declaration
public virtual float flexibleHeight { get; }
Property Value
| Type | Description |
|---|---|
| float |
flexibleWidth
Flexible width weight reported to native uGUI containers. Returns -1,
indicating the stack does not participate in flexible width distribution in the
native layout system.
Declaration
public virtual float flexibleWidth { get; }
Property Value
| Type | Description |
|---|---|
| float |
layoutPriority
Layout priority reported to native uGUI containers. Returns 1, which is
above the default uGUI priority of 0, so the stack's preferred dimensions
win over those of plain ILayoutElement components on the same GameObject.
Declaration
public virtual int layoutPriority { get; }
Property Value
| Type | Description |
|---|---|
| int |
minHeight
Minimum height reported to native uGUI parent containers. Always 0; Scylla
stacks do not advertise a minimum height to the native layout system.
Declaration
public virtual float minHeight { get; }
Property Value
| Type | Description |
|---|---|
| float |
minWidth
Minimum width reported to native uGUI parent containers. Always 0; Scylla
stacks do not advertise a minimum width to the native layout system.
Declaration
public virtual float minWidth { get; }
Property Value
| Type | Description |
|---|---|
| float |
preferredHeight
Content-driven preferred height reported to native uGUI parent containers. Analogous to preferredWidth for the vertical axis.
Declaration
public virtual float preferredHeight { get; }
Property Value
| Type | Description |
|---|---|
| float |
preferredWidth
Content-driven preferred width reported to native uGUI parent containers such as
ScrollRect. This value equals the hugWidth output from the last
SolveAndApply(float, float) call and reflects the stack's aggregate child
content width plus padding.
Declaration
public virtual float preferredWidth { get; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
CalculateLayoutInputHorizontal()
Called by Unity's layout system before horizontal layout is computed. This implementation is a no-op; Scylla stacks perform their own measurement inside SolveAndApply(float, float) rather than through Unity's two-phase layout API.
Declaration
public virtual void CalculateLayoutInputHorizontal()
CalculateLayoutInputVertical()
Called by Unity's layout system before vertical layout is computed. This implementation is a no-op for the same reason as CalculateLayoutInputHorizontal().
Declaration
public virtual void CalculateLayoutInputVertical()
MarkDirty()
Marks this stack as needing a layout solve on the next frame flush. The call is
cheap and idempotent: multiple calls before the next flush produce only a single
solve. When a ScyllaUILayoutRoot ancestor is present, the stack is
enqueued in the root's dirty set; without a root it will self-solve in its own
LateUpdate when the _isDirty flag is checked.
Declaration
public void MarkDirty()
OnDestroy()
Backstop teardown that clears the driven tracker and unregisters from the root in case OnDisable() did not run cleanly. Prevents child transforms from retaining stale "driven by..." ghosts after the stack is destroyed.
Declaration
protected override void OnDestroy()
Overrides
OnDisable()
Clears the UnityEngine.DrivenRectTransformTracker so children stop showing "driven by..." locks in the Inspector, and unregisters the stack from its ScyllaUILayoutRoot. Called when the component or its GameObject is deactivated.
Declaration
protected override void OnDisable()
Overrides
OnEnable()
Registers the stack with its nearest ancestor ScyllaUILayoutRoot and marks the stack dirty so the first solve runs on the next frame flush. Called when the component or its GameObject is activated.
Declaration
protected override void OnEnable()
Overrides
OnRectTransformDimensionsChange()
Marks the stack dirty when Unity reports that the RectTransform's dimensions have changed (e.g. a parent layout group resized this stack's rect). Called by Unity's layout rebuild cycle.
Declaration
protected override void OnRectTransformDimensionsChange()
Overrides
OnTransformParentChanged()
Re-registers the stack with the correct ScyllaUILayoutRoot after a reparent, then marks the stack dirty. Called by Unity whenever the immediate parent Transform changes.
Declaration
protected override void OnTransformParentChanged()