Class ScyllaUIAdaptiveStack
Orientation-responsive stack that switches between horizontal and vertical layout at runtime based on the parent viewport's aspect ratio. Useful for UI surfaces that should reflow between landscape (side-by-side) and portrait (top-to-bottom) without designer intervention. Extends ScyllaUIStackBase with a dynamically computed IsHorizontal orientation.
Inheritance
Implements
Inherited Members
Namespace: Scylla.Core.Util.UI
Assembly: ScyllaCore.dll
Syntax
[AddComponentMenu("Scylla/UI/Layout/Adaptive Stack")]
public sealed class ScyllaUIAdaptiveStack : ScyllaUIStackBase, ILayoutElement
Remarks
The stack reads its parent UnityEngine.RectTransform's aspect ratio on every
solve. When the parent's width / height ratio is greater than or equal to
AspectThreshold, the stack lays out horizontally; otherwise
vertically. The default threshold of 1.0 corresponds to a square
viewport: anything wider is horizontal, anything taller is vertical.
All other layout properties (padding, spacing, alignment, sizing modes) are shared between the horizontal and vertical orientation. For per-orientation overrides, assign a ScyllaUILayoutStyle with aspect-ratio breakpoints.
Resolution and orientation changes propagate through the owning
ScyllaUILayoutRoot's watcher; without a root the stack's own
OnRectTransformDimensionsChange hook fires the dirty mark automatically.
Properties
AspectThreshold
Aspect ratio threshold (width / height) at which the stack flips orientation. Values >= 1 keep landscape horizontal; values < 1 favor vertical layout.
Declaration
public float AspectThreshold { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
IsHorizontal
Computed orientation. Returns true (horizontal) when the parent
RectTransform's current width / height ratio is at or above
AspectThreshold; returns false (vertical) otherwise.
Evaluated lazily on every read so the value always reflects the current viewport.
Declaration
public override bool IsHorizontal { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
Remarks
When the parent RectTransform is absent, the getter falls back to comparing
AspectThreshold against 1.0: if the threshold is 1.0 or
below (meaning landscape-or-square is horizontal), the getter returns
true; otherwise false. When the parent rect has a non-positive
height, the getter returns true (horizontal) as a safe default.