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):
- To minimise the initial download size of the app, use StreamingAssets instead of Resources folders – as resources get bundled with the download.
- 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.
- 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.
- 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.
- 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.
- 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.
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).
- 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.
- 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!