Every dimension in Paper — width, height, margin, padding, position — is expressed as aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ProwlEngine/Prowl.Paper/llms.txt
Use this file to discover all available pages before exploring further.
UnitValue. Instead of overloaded method signatures for different unit types, UnitValue is a single composite value that can represent pixels, a percentage of the parent, a share of leftover space, or automatic content sizing — and any combination of those at once.
The Four Unit Types
UnitValue stores four independent components internally: Px, Pct, Grow, and AutoFactor. Each factory method sets one of them:
| Type | Factory | Shorthand | Internal field set |
|---|---|---|---|
| Pixels | UnitValue.Pixels(200f) | paper.Pixels(200f) | Px = 200 |
| Percentage | UnitValue.Percentage(50f) | paper.Percent(50f) | Pct = 50 |
| Stretch | UnitValue.Stretch(1f) | paper.Stretch(1f) | Grow = 1 |
| Auto | UnitValue.Auto | paper.Auto | AutoFactor = 1 |
Pixels
A fixed pixel length. Unaffected by the parent’s size.Percentage
A fraction of the parent container’s corresponding dimension, with an optional pixel offset baked in.offset parameter is the second argument to UnitValue.Percentage(float value, float offset) and maps directly to the Px component.
Stretch
Stretch values claim a share of the leftover space in the parent’s main axis after all fixed and percentage children have been measured. The share is weighted by theGrow factor.
UnitValue.StretchOne is a pre-allocated constant equal to Stretch(1f) — used internally by the no-argument ChildLeft(), ChildRight(), etc. overloads.
Auto
Auto sizes the element to its content. For containers, that means wrapping tightly around children. For leaf elements with aContentSizer, it calls the sizer function. For text elements, it measures the rendered text.
paper.Auto is a property (not a method) because it takes no arguments. The other three are methods: paper.Pixels(v), paper.Percent(v), paper.Stretch(f).Composite Values
BecauseUnitValue stores all four components simultaneously, you can combine units using standard arithmetic operators. This falls out naturally from the struct design — addition merges components independently.
Weighted Stretch Distribution
When multiple siblings all haveStretch widths (or heights), the engine divides the leftover space proportionally by their Grow factors.
paper.Stretch() with no argument defaults to a factor of 1f. UnitValue.StretchOne is a pre-allocated singleton for the same value, used by alignment helpers to avoid allocations.
Stretch factors are relative within the pool of stretch siblings.
Stretch(2) vs. Stretch(1) gives a 2:1 split. Stretch(4) vs. Stretch(2) gives the same 2:1 split — only the ratio matters.Arithmetic Operators
UnitValue supports the full set of arithmetic operators. Each operates component-wise across Px, Pct, Grow, and AutoFactor:
float and int produce UnitValue.Pixels(value), so you can pass raw numbers anywhere a UnitValue is expected:
Lerping UnitValues for Animation
UnitValue.Lerp(a, b, t) interpolates each component independently. This integrates naturally with Paper’s built-in transition system, but you can also call it manually when driving animations from your own timer:
Pixels(0) to Auto at t = 0.5 gives { AutoFactor = 0.5 }, meaning “half the content size”.
Quick Reference
Pixels
Fixed size in logical pixels. Unaffected by the parent.
Percentage
Fraction of the parent’s dimension, plus an optional pixel offset.
Stretch
Claims a weighted share of leftover space after fixed children are measured.
Auto
Sizes to content — children,
ContentSizer, or measured text.