Day 11 – Android & UI

Today I did my first Android build and ran it on my Nokia 8.1. All went smoothly – kudos to Unity for making the process of building for Android error-free and “just works”.

Photo of the game running on a smart phone

This showed a couple of issues:

  1. The camera’s clipping the edges of the map; it was simple enough to fix this with a script that adjusted the camera’s ortho size based on the grid dimensions and screen aspect ratio.
  2. When you run out of track, you have to kill the app and restart it. This has been annoying me for a while in the Editor, so I decided to crack on with…

UI

I’ve only briefly used Unity UI before, so I did a bit of reading, and setup a Game Over screen with a Restart button that works via the built-in trigger system – just point it at the GameController object and select the “NewGame” function – job done!

I then spent a while figuring out how to stick a background image behind the entire game to fill-in the grey bars at the top & bottom, and also the gaps you can see when tiles rotate. I grabbed a wallpaper off the internet (which I’ll replace with something bespoke later), and put it on a camera-space UI attached to the camera, positioned behind everything else in the scene.

Tomorrow – more UI I think; perhaps a speedo and score counter.

Leave a comment