UIAspectRatio
Locks width/height ratio to prevent stretching of UI elements.
Create in the Editor
- Ensure there is a
UIControllerin the scene. - Create a GameObject and add
UIRect. - Add the
UIAspectRatiocomponent.
How to Use
- Get the component with
myObject.findComponent(UIAspectRatio.class). - Read and write the component properties to control behavior.
- Test input or layout in Play mode.
Java Example
SpatialObject myObject = /* your object */;
UIAspectRatio comp = myObject.findComponent(UIAspectRatio.class);
if (comp != null) {
// set the mode value:
comp.mode = new Mode();
// read the mode value:
Mode modeValue = comp.mode;
// set the proportion value:
comp.proportion = 1f;
// read the proportion value:
float proportionValue = comp.proportion;
}