Pular para o conteúdo principal

UIRect

Define os limites do elemento (posicao, tamanho, padding e margin) usados por layout e hit test.

Criar no Editor

  1. Garanta que existe um UIController na cena.
  2. Crie um GameObject e adicione UIRect.
  3. Adicione o componente UIRect.

Como Usar

  1. Pegue o componente com myObject.findComponent(UIRect.class).
  2. Leia e altere as propriedades do componente para controlar o comportamento.
  3. Teste o input ou layout no modo Play.

Exemplo em Java

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;

}