TapPhrase – update

I thought I might just write a little bit about my journey so far with trying to get TapPhrase into Unity to run as a Facebook WebGL game, rather than GameRoom game.

There’s so much I could write – but some major points here which I fell foul of (because of the WebGL decision):

  1. To minimise the initial download size of the app, use StreamingAssets instead of  Resources folders – as resources get bundled with the download.
  2. Storage on the web is predominantly in the browser’s memory, so (I believe) you end up using twice the memory for every asset. Thus, I reduced the number of music tracks significantly to reduce download size.
  3. You can only have 500 files in your Web GL zip file – so I’ve had to pack up my levels into groups of 10 or 20 and put them as streaming assets in zip files. I srtream the zip file (into memory), unpack (into memory) then delete the zip file, then convert images into Texture2D, then delete the unpacked files. Originally I had a beautiful background operation that would gently load the next few pictures in advance, but now I have an ugly loading/unpacking dialog.
  4. Unless you want to use fullscreen, make your own unity template in Macintosh HD⁩ ▸ ⁨Applications⁩ ▸ ⁨Unity⁩ ▸ ⁨PlaybackEngines⁩ ▸ ⁨WebGLSupport⁩ ▸ ⁨BuildTools⁩, and hack the index.html file so that you hide the full-screen button.
  5. Create an appropriately sized configuration in Unity with which to run your game – as you can see from this screen shot, I made a few mistakes. Screenshot 2019-08-18 at 13.58.51
  6. You may get errors that just don’t appear in the Unity UI while debugging – I got Error: Out of bounds Trunc operation” (evaluating ‘Module[“asm”][“dynCall_v”].apply(null, arguments)’) – This was because I managed to pass  NaN to Mathf.Lerp’s t parameter. It was quite hard to track down because the call stack gave no clue to the location in code, only what type of operation was being performed. I got lucky and guessed.
  7. Storage of player data – At first I used Application.persistentDataPath  and extra calls to a file sync operation call out to Javascript –[DllImport(“__Internal”)]
    private static extern void SyncFiles(); – calling out to HandleIO.jslib, but
     then you can get warnings telling you that you’re calling file-sync too many times. I then had a facepalm moment and realised that of course, that’s saving player state within the browsers memory/cache. If they log in to facebook with a different computer or browser, that game state is NOT going to be there. So I’m now looking at alternatives like PlayFab (free).
  8. I was hoping to not bother with in-app purchases and just use advertising revenue as a little mini-income stream. It gave me a few quid each month on iOS, not anywhere near break-even, but something that helped. However, Unity’s advertising api doesn’t support WebGL! WTF! So that’s out of the window. I’ll have to go back to in-app purchases and learn facebook’s payments API. Or give another game away totally free.
  9. I think next time I’ll stick to mobile or try GameRoom. Instant messenger games have some appeal, but you’re limited to 200mb.

Until the next update!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s