0

Original post: http://answers.unity3d.com/questions/1350392/webgl-build-not-using-custom-unityprogressjs.html

I have a Unity project that I have deployed in WebGL. In the Assets/WebGLTemplates folder I have custom template data.

Index.html

 <!DOCTYPE html>
 <html lang="en-us">
   <head>
     <meta charset="utf-8">
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     <title>%UNITY_WEB_NAME%</title>
     <link rel="stylesheet" href="TemplateData/style.css">
     <script src="TemplateData/UnityProgress.js"></script>  
     <script src="%UNITY_WEBGL_LOADER_URL%"></script>
     <script>
       var gameInstance = UnityLoader.instantiate("gameContainer", "%UNITY_WEBGL_BUILD_URL%");
     </script>
   </head>
   <body>
     <div id="gameContainer" style="width: %UNITY_WIDTH%px; height: %UNITY_HEIGHT%px; margin: auto"></div>
   </body>
 </html>

TemplateData/UnityProgress.js

 function UnityProgress(gameInstance, progress) {
   if (!gameInstance.Module)
     return;
   if (!gameInstance.logo) {
       gameInstance.logo = document.createElement("div");
       console.log("Try it out");
     //gameInstance.logo.className = "logo " + gameInstance.Module.splashScreenStyle;
     //gameInstance.container.appendChild(gameInstance.logo);
   }
 ...

Trouble is, Unity recognizes the custom template but insists on using its own UnityLoader which has the Unity logo in the loader intact (which the custom loader removes). As a workaround, I have inserted the custom template within the Unity folders itself, and it works as expected. However, I would like to manage the template files within the project itself (so that it is machine independent).

I could not find any documentation on the TemplateData even though I feel like I'm missing something REALLY obvious...

...and I haven't received a reply on the Unity forums for about a week now.

gman
  • 100,619
  • 31
  • 269
  • 393
sweng
  • 1
  • 1
  • 3

1 Answers1

0

I think the problem is that you are missing the call to initialise progress in the instantiate function

 <script>
       var gameInstance = UnityLoader.instantiate("gameContainer", "%UNITY_WEBGL_BUILD_URL%", {onProgress: UnityProgress});
 </script>
Real World
  • 1,593
  • 1
  • 21
  • 46