Skip to main content

UIRect

Defines the UI element bounds (position, size, padding, and margins) used by layout and hit testing.

Create in the Editor​

  1. Ensure there is a UIController in the scene.
  2. Create a GameObject and add UIRect.
  3. Add the UIRect component.

How to Use​

  1. Get the component with myObject.findComponent(UIRect.class).
  2. Read and write the component properties to control behavior.
  3. Test input or layout in Play mode.

Java Example​

SpatialObject myObject = /* your object */;
UIRect comp = myObject.findComponent(UIRect.class);
if (comp != null) {
// set the marginBottom value:
comp.marginBottom = 1;
// read the marginBottom value:
int marginBottomValue = comp.marginBottom;

// set the marginLeft value:
comp.marginLeft = 1;
// read the marginLeft value:
int marginLeftValue = comp.marginLeft;

// set the marginRight value:
comp.marginRight = 1;
// read the marginRight value:
int marginRightValue = comp.marginRight;

// set the marginTop value:
comp.marginTop = 1;
// read the marginTop value:
int marginTopValue = comp.marginTop;

// set the paddingBottom value:
comp.paddingBottom = 1;
// read the paddingBottom value:
int paddingBottomValue = comp.paddingBottom;

// set the paddingLeft value:
comp.paddingLeft = 1;
// read the paddingLeft value:
int paddingLeftValue = comp.paddingLeft;

// set the paddingRight value:
comp.paddingRight = 1;
// read the paddingRight value:
int paddingRightValue = comp.paddingRight;

// set the paddingTop value:
comp.paddingTop = 1;
// read the paddingTop value:
int paddingTopValue = comp.paddingTop;

// set the position value:
comp.position = 1;
// read the position value:
int positionValue = comp.position;

// set the positionX value:
comp.positionX = 1;
// read the positionX value:
int positionXValue = comp.positionX;

// set the positionY value:
comp.positionY = 1;
// read the positionY value:
int positionYValue = comp.positionY;

// set the size value:
comp.size = 1;
// read the size value:
int sizeValue = comp.size;

// set the sizeX value:
comp.sizeX = 1;
// read the sizeX value:
int sizeXValue = comp.sizeX;

// set the sizeY value:
comp.sizeY = 1;
// read the sizeY value:
int sizeYValue = comp.sizeY;

}