UIAspectRatioConstraint
UIAspectRatioConstraint : Instance
Overview
An instance that can be used to force UI element to maintain its specified aspect ratio even when the element is affected by screen size change or parent element ratio. For example, if aspect ratio is set to 2:1, width will always twice the length of height; if aspect ratio is set to 1:1, it will always be square regardless of its environment.
It is particularly effective when dealing with UI element of which quality drops when a fixed aspect ratio is disturbed, like square image. In addition, even when in situation where UI layout attempts to change element size with UIGridLayout, UIListLayout, or others, aspect ratio limitation is applied on top of other aspect ratios when the size of UI object is determined.
UIAspectRatioConstraint can be controlled only in client environment.
Properties
AspectRatio
number
Specifies which aspect ratio UI element must maintain.
For example, if 2 is given, width become twice height. On the other hands, if vertical ratio must be maintained, use the multiplicative inverse of the number.
This value must be greater than 0 to work properly. An invalid aspect ratio value may prevent limitation conditions from working properly.
Code Samples
local UIAspectRatioConstraint = script.Parent
UIAspectRatioConstraint.AspectRatio = 2AspectType
Enum.AspectType
A way to control how much UI element can be expanded.
If FitWithinMaxSize is selected, object is drawn as big as it does not exceed its actual size (AbsoluteSize); if ScaleWithParentSize is selected, its size will be adjusted as big as it can be based on the size of its parent UI.
Code Samples
DominantAxis
Enum.DominantAxis
Determines in which axis (horizontal or vertical) UI element is adjusted when the UI element tries to become larger than its parent. In other words, it defines the axis that will become a reference point when UI element is adjusted so that it will not exceed its limitation imposed by its parent.
Code Samples
Methods
Events
See also
GUILast updated