Forum Multiplayer WebGL build - Unity 2020.3

Discussion and help relating to the PlayerIO Multiplayer API.

WebGL build - Unity 2020.3

Postby Nerdzul » March 27th, 2021, 6:39 pm

Heya, I have been away from Unity for a while and recently updated a project using Unity 2020 (I think it was made with the 2018 version), as usual I have rebuilt the WebGL version (without any significant changes to the code), the game loads fine, but now when I try form a connection I got this message:

UnityLoader.instantiate() should be stored in a global variable


I have noticed that this new version of unity builds a very different htlm file than the one I was accustomed to using.

Can you help me out finding a solution?

EDIT: Took me a while, but I solved it, editing the index a bit, turns out that reading the error explains the error hehe....
Nerdzul
 
Posts: 1
Joined: July 11th, 2018, 10:39 pm

Re: WebGL build - Unity 2020.3

Postby wbsaputra » November 4th, 2021, 6:57 am

hey how you solved it?
I think the problem is this code from default template too.

yeap, solved it;
for anyone has same problem here is the fix:
Code: Select all
      var gameInstance;
      script.onload = () => {
        createUnityInstance(canvas, config, (progress) => {
          progressBarFull.style.width = 100 * progress + "%";
        }).then((unityInstance) => {
            gameInstance = unityInstance;
          loadingBar.style.display = "none";
          fullscreenButton.onclick = () => {
            unityInstance.SetFullscreen(1);
          };
        }).catch((message) => {
          alert(message);
        });
      };
wbsaputra
Paid Member
 
Posts: 150
Joined: June 29th, 2010, 4:38 pm


Return to Multiplayer



cron