Class
UIAspectRatioConstraint
Ensures the parent UI element maintains a particular aspect ratio.
The UIAspectRatioConstraint enforces a width‑to‑height aspect
ratio on a GuiObject regardless of its core size, even if that size is
set as a percentage of its parent. For example, inserting this constraint as a
child of a Frame and setting the constraint's
AspectRatio property to 2
(2:1) keeps the frame's width at twice that of its height. Similarly,
setting this constraint's
AspectRatio property to 0.5
(0.5:1) keeps the frame's width at half that of its height.
Setting this constraint's
AspectRatio to the default of 1
(1:1) is a convenient way to prevent non‑proportional scaling/stretching of
an ImageLabel with a square image asset.
Note that when a UI object is under control of both a layout structure such as
UIListLayout and a UIAspectRatioConstraint, the constraint
will override the layout and control the object's size.
Properties 3#
AspectRatiofloat | Determines the width-to-height ratio to maintain.ReadSafe |
AspectTypeAspectType | Determines how the maximum size of the object is limited.ReadSafe |
DominantAxisDominantAxis | Determines the axis to use when setting the new size of the object.ReadSafe |
AspectRatio: float#
ReadSafe
This property determines the width‑to‑height ratio to maintain. To flip
the ratio to height‑to‑width, take the inverse (divide 1 by the number
or raise to the -1st power). This value must be greater than 0.
AspectType: AspectType#
ReadSafe
This property determines how the maximum size of the object is limited.
When set to
FitWithinMaxSize, the object will be the maximum size possible within its ownAbsoluteSize.When set to
ScaleWithParentSize, the object's maximum size will be the size of the parent while still maintaining the aspect ratio.
DominantAxis: DominantAxis#
ReadSafe
This property determines which axis to use when setting the new size of the object, assuming it would otherwise exceed the size of the parent.
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild