How to setup the dev environment


* All art assets are from Unity Tiny Mode's demo: Galaxy Raider; I do not own them

Summary:

To demonstrate how to create multiplayer H5 games using Unity Tiny Mode + Photon Javascript SDK

Steps:

  • Installed tiny mode module (it is still in preview, so you need to allow preview packages to be shown

  • Download Photon Javascript SDK
  • Create a folder “External” side by side with asset folder and put the photon sdk there
  • Photon javascript sdk comes with 3 versions, and you can just keep one

  • Create tsconfig.override.json side by side with .utproject

  • Content of the tsconfig.override.json
    • To simplify, I just include all javascript files under the external folder 
    • If you do this, make sure you only keep one set of javascript sdk
    • In our case, we only keep 
      • Photon-Javascript_SDK.js 
      • Photon-Javascript_SDK.d.ts

  • Setup photon service script to initialize photon 
    • Based on photon tutorial, we add a new class extends Photon.LoadBalancing.LoadBalancingClient
    • Make sure you add reference path on the top, otherwise photon won’t be recognized
    • You need to include both .js & .d.ts for your reference path. .js is used so photon namespace can be recognized. .d.ts is used so photon can be used for variable type declaration

 

  • Somewhere in your code, call the photon class to start

That’s it!

Note:

  • If you are not familiar with typescript, make sure you add “export” at the beginning of the new class you created, otherwise other classes won’t be able to recognize the new class

Resources:

https://www.youtube.com/watch?v=V4GoBnhxKyw

https://forum.unity.com/threads/can-the-typescript-engine-run-regular-javascript-code.594064/

Leave a comment

Log in with itch.io to leave a comment.