Pular para o conteúdo principal

UIAlignment

Alinha o elemento dentro do pai com regras horizontais e verticais.

Criar no Editor

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

Como Usar

  1. Pegue o componente com myObject.findComponent(UIAlignment.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 */;
UIAlignment comp = myObject.findComponent(UIAlignment.class);
if (comp != null) {
// set the bottomCenterEnabled value:
comp.bottomCenterEnabled = true;
// read the bottomCenterEnabled value:
boolean bottomCenterEnabledValue = comp.bottomCenterEnabled;

// set the bottomLeftEnabled value:
comp.bottomLeftEnabled = true;
// read the bottomLeftEnabled value:
boolean bottomLeftEnabledValue = comp.bottomLeftEnabled;

// set the bottomRightEnabled value:
comp.bottomRightEnabled = true;
// read the bottomRightEnabled value:
boolean bottomRightEnabledValue = comp.bottomRightEnabled;

// set the centerEnabled value:
comp.centerEnabled = true;
// read the centerEnabled value:
boolean centerEnabledValue = comp.centerEnabled;

// set the centerLeftEnabled value:
comp.centerLeftEnabled = true;
// read the centerLeftEnabled value:
boolean centerLeftEnabledValue = comp.centerLeftEnabled;

// set the centerRightEnabled value:
comp.centerRightEnabled = true;
// read the centerRightEnabled value:
boolean centerRightEnabledValue = comp.centerRightEnabled;

// set the topCenterEnabled value:
comp.topCenterEnabled = true;
// read the topCenterEnabled value:
boolean topCenterEnabledValue = comp.topCenterEnabled;

// set the topLeftEnabled value:
comp.topLeftEnabled = true;
// read the topLeftEnabled value:
boolean topLeftEnabledValue = comp.topLeftEnabled;

// set the topRightEnabled value:
comp.topRightEnabled = true;
// read the topRightEnabled value:
boolean topRightEnabledValue = comp.topRightEnabled;

}