Skip to main content

UIDynamicJoystick

Joystick that appears where the user touches and outputs a 2D axis value.

Create in the Editor

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

How to Use

  1. Get the component with myObject.findComponent(UIDynamicJoystick.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 */;
UIDynamicJoystick comp = myObject.findComponent(UIDynamicJoystick.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 handleSize value:
comp.handleSize = 1;
// read the handleSize value:
int handleSizeValue = comp.handleSize;

// 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;

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

}

Notes

  • You can replace images or textures in the inspector or via code when the component supports it.