Setting up the eight-directional virtual analog stick

To create an analog stick that moves in eight directions, as shown in the previous image, complete the following steps:

  1. Create a new scene named Chapter10Example3 in the Assets/Scenes folder and open the new scene.
  2. Create a new image with Create | UI | Image. Name the new image Stick Base.
  3. Add the d-pad buttons_15 sprite to the Source Image slot of its image component.
  4. Right-click Stick Base in the hierarchy and select UI | Image to add an image child to the Stick Base. Name the child Stick.
  1. Resize the Stick image to match the Stick Base by setting its Rect Transform stretch and anchor to stretch fully across both directions.
  2. Add the d-pad buttons_0 sprite to the Source Image slot of ...

Get Mastering UI Development with Unity now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.