Pular para o conteúdo principal

UIJoystick

Joystick na tela que gera um eixo 2D baseado no toque.

Criar no Editor

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

Como Usar

  1. Pegue o componente com myObject.findComponent(UIJoystick.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 */;
UIJoystick comp = myObject.findComponent(UIJoystick.class);
if (comp != null) {
Texture tex = /* load texture */ null;
// set the backgroundColor value:
comp.backgroundColor = new Color(255, 255, 255, 255);
// read the backgroundColor value:
Color backgroundColorValue = comp.backgroundColor;

// set the backgroundTexture value:
comp.backgroundTexture = tex;
// read the backgroundTexture value:
Texture backgroundTextureValue = comp.backgroundTexture;

// set the handleSizePercentage value:
comp.handleSizePercentage = 1f;
// read the handleSizePercentage value:
float handleSizePercentageValue = comp.handleSizePercentage;

// set the handlerColor value:
comp.handlerColor = new Color(255, 255, 255, 255);
// read the handlerColor value:
Color handlerColorValue = comp.handlerColor;

// set the handlerTexture value:
comp.handlerTexture = tex;
// read the handlerTexture value:
Texture handlerTextureValue = comp.handlerTexture;

}

Notas

  • Voce pode substituir imagens ou texturas no inspetor ou via codigo quando o componente suporta isso.