Layout2D#
A Layout 2D component: the object is a rectangle of Width × Height local units placed by rules instead of a hand-set position. AnchorX/AnchorY (0…1) pick a point of the container (the parent's Layout 2D rectangle, else the layer camera's frame); PivotX/PivotY pick the point of this rectangle placed there; OffsetX/OffsetY move it in units. A container with Direction "row" or "column" lays its Layout 2D children out in order with Gap between them inside Padding, aligned across the axis by Align ("start", "center", "end"); their anchors are then ignored. Positions are written to the objects' local 2D transform each frame the frame or a rule changes; rotation and scale stay the author's.
public sealed record Layout2D(float Width = 1, float Height = 1, float AnchorX = .5f, float AnchorY = .5f, float PivotX = .5f, float PivotY = .5f, float OffsetX = 0, float OffsetY = 0, string Direction = "none", float Gap = 0, float Padding = 0, string Align = "center")Record properties#
| Property | Type | Access | Constructor default |
|---|---|---|---|
Width | float | get; init; | 1 |
Height | float | get; init; | 1 |
AnchorX | float | get; init; | .5f |
AnchorY | float | get; init; | .5f |
PivotX | float | get; init; | .5f |
PivotY | float | get; init; | .5f |
OffsetX | float | get; init; | 0 |
OffsetY | float | get; init; | 0 |
Direction | string | get; init; | "none" |
Gap | float | get; init; | 0 |
Padding | float | get; init; | 0 |
Align | string | get; init; | "center" |
Source#
- RuntimeWorld.cs