UIAspectRatioConstraint
Ensures the parent UI element maintains a particular aspect ratio.
Memory category | Instances |
---|
Member index 3
Description
A UIAspectRatioConstraint ensures that the parent UI element (GuiObject) maintains a particular aspect ratio even if its size is set as a percentage of its parent. If an object with this constraint is also under the control of a UILayout such as UIGridLayout, then the constraint controls the objects size and overwrites any size the layout would apply.
When applied to a GuiObject, the UIAspectRatioConstraint will make sure that the objects ratio is maintained by the value defined in UIAspectRatioConstraint.AspectRatio. The UIAspectRatioConstraint.AspectType sets what determines the maximum size of the object. When set to AspectType.FitWithinMaxSize, the constraint will make the object the maximum size it can be within the GuiObject of the element. When set to ScaleWithParentSize, the elements maximum size will be the size of the parent while still maintaining the aspect ratio. Finally, the UIAspectRatioConstraint.DominantAxis will determine which axis to use when setting the new size of the element.
History 13
- 553 Change Default of DominantAxis from to Width
- 553 Change Default of AspectType from to FitWithinMaxSize
- 553 Change Default of AspectRatio from to 1
- 486 Change ThreadSafety of DominantAxis from ReadOnly to ReadSafe
- 486 Change ThreadSafety of AspectType from ReadOnly to ReadSafe
- 486 Change ThreadSafety of AspectRatio from ReadOnly to ReadSafe
- 462 Change ThreadSafety of DominantAxis from to ReadOnly
- 462 Change ThreadSafety of AspectType from to ReadOnly
- 462 Change ThreadSafety of AspectRatio from to ReadOnly
- 266 Add DominantAxis
- 266 Add AspectType
- 266 Add AspectRatio
- 266 Add UIAspectRatioConstraint
Members 3
AspectRatio
Type | Default | |
---|---|---|
float | 1 |
AspectRatio 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 zero. Below, a white Frame is placed within the a black Frame with two different width-to-height ratios.
Thread safety | ReadSafe |
---|---|
Category | Behavior |
Loaded/Saved | true |
History 4
- 553 Change Default of AspectRatio from to 1
- 486 Change ThreadSafety of AspectRatio from ReadOnly to ReadSafe
- 462 Change ThreadSafety of AspectRatio from to ReadOnly
- 266 Add AspectRatio
AspectType
Type | Default | |
---|---|---|
AspectType | FitWithinMaxSize |
AspectType determines what limits the maximum size of the element.
- When set to FitWithinMaxSize, the constraint will make the object the maximum size it can be within its own GuiBase2d.AbsoluteSize.
- When set to ScaleWithParentSize, the UI element's maximum size will be the size of the parent while still maintaining the aspect ratio..
Thread safety | ReadSafe |
---|---|
Category | Behavior |
Loaded/Saved | true |
History 4
- 553 Change Default of AspectType from to FitWithinMaxSize
- 486 Change ThreadSafety of AspectType from ReadOnly to ReadSafe
- 462 Change ThreadSafety of AspectType from to ReadOnly
- 266 Add AspectType
DominantAxis
Type | Default | |
---|---|---|
DominantAxis | Width |
DominantAxis determines which axis to use when setting the new size of the UI element if it would otherwise exceed the size of the parent.
Thread safety | ReadSafe |
---|---|
Category | Behavior |
Loaded/Saved | true |
History 4
- 553 Change Default of DominantAxis from to Width
- 486 Change ThreadSafety of DominantAxis from ReadOnly to ReadSafe
- 462 Change ThreadSafety of DominantAxis from to ReadOnly
- 266 Add DominantAxis