I wanted the game to be accessible on mobile so I made it compatible with android devices. After changing some settings in Unity, I was able to create a build of the game that opened on an android device. However, it was not possible to get past the start screen as new API systems were required.
I decided to add a guest mode that bypasses the API authorisation so that I could test the rest of the game on android. I did this by adding a guest button to the start screen that runs an alternate load function which doesn’t start the authorisation process and opens the main game instead. I found that the game canvas didn’t fit the screen, so I changed the canvas settings to match width and height evenly to scale correctly across devices.
To make the new API authorisation system, I first had to make the sign in button open the webpage. To do this, I added a platform check so that if the player was on PC, it would run the existing code. If the player is using an android device, it will run the new code with a strava URL specific to mobile, and a different redirect page.
Windows authorisation
Android authorisation
Originally the redirect page was part of my website, and I embedded html to reopen the game. However, my website is built on google sites, so this opened an iframe and ran inside of the site instead of directing the user back to the game. I found that github pages could be used, which is a free feature of github that can be used to host code on a website.
Using this, I was able to direct the user back to the game after they authorised Strava, but the game still displayed the sign in button. This was because the PC setup used an authorisation listener that saved the user’s data and loaded the main game, but this didn’t work on android. To fix this I added a script to track and process the redirect so that when the game is reopened, it then runs the function from the authorisation listener to save data and load the game.
On android, the loading bar was running much slower than on PC due to the lower framerate. I made the bar increase by a standardised amount regardless of framerate to fix this.