Unity to Facebook Sync for GameLoading not working
1

I have gone through endless pages and i cannot seem to find any help for uploading unity to facebook instant - what am i missing? The only posts i can find are to do with Unity Tiny which is not available anymore. I'll post my scripts below but i really need some help i don't know what I'm missing:

Saved in a Zip File within Zip File - // Build - data.unityweb / build.json / build.wasm.code.unityweb / build.wasm.framework.unityweb / UnityLoader.js // External - FBInstant.d.ts // index.html // TemplateData - favicon.ico / (progress png's ) / unityProgress.js , etc etc // tsconfig.override.json

//index.html :

Unity WebGL Player | Quokka Quads
<script src="https://connect.facebook.net/en_US/fbinstant.6.2.js"></script>

<script src="Build/UnityLoader.js"></script>
   <script>
var p = 0;
  FBInstant.initializeAsync()
  .then(function() {
    //FBInstant.setLoadingProgress(50);
    //FBInstant.setLoadingProgress(100);    
  });

  // Once all assets are loaded, tells the SDK
  // to end loading view and start the game

  FBInstant.startGameAsync()
   .then(function() {
     // Retrieving context and player information can only be done
     // once startGameAsync() resolves
     var contextId = FBInstant.context.getID();
     var contextType = FBInstant.context.getType();
}

<script>

FBInstant.initializeAsync().then(function () {
        var gameInstance = UnityLoader.instantiate("gameContianer", "Build/QQNoMusicBuild.json", { onProgress: UnityProgress });
    });</script>

Quokka Quads

// tsconfig.override.json

{ "compilerOptions": { "allowJs": true }, "include": [ "External/FBInstant//*.js", "External/FBInstant//*.ts", ], "files": [ "External/dst/FBInstant.d.ts" ] }

I really am stuck i don't know what to do - the game works fine on itchio & simmer...but i don't know what to do to get it to work on Facebook

Jack
Asked about 8 months ago
Selected Answer
1

Finally after weeks i managed to get it sorted...looks like there were a few tiny things i missed and one stupid thing i missed in the unity progress which is the line : game.start(); ...which would help! For those who also had this issue here is the working fix:

  <!DOCTYPE html>
     <html lang="en-us">
       <head>
         <meta charset="utf-8">
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
         <title>Unity WebGL Player | INSERT GAME TITLE HERE</title>
         <link rel="shortcut icon" href="TemplateData/favicon.ico">
         <link rel="stylesheet" href="TemplateData/style.css">
         <script src="TemplateData/UnityProgress.js"></script>         
         <script src="https://connect.facebook.net/en_US/fbinstant.6.3.js"></script>       
         <script src="Build/UnityLoader.js"></script>
         <script>FBInstant.initializeAsync().then(function() {
 var gameInstance = UnityLoader.instantiate("gameContainer", "Build/INSERT GAME TITLE HERE.json", {onProgress: UnityProgress});
            });    
         </script>
       </head>
       <body>
         <div class="webgl-content">
           <div id="gameContainer" style="width: 960px; height: 600px"></div>
           <div class="footer">
             <div class="webgl-logo"></div>
             <div class="fullscreen" onclick="gameInstance.SetFullscreen(1)"></div>
             <div class="title">INSERT GAME TITLE HERE</div>
           </div>
         </div>
       </body>
     </html>
function UnityProgress(gameInstance, progress) {
    if (!gameInstance.Module)
        return;
    if (!gameInstance.logo) {
        gameInstance.logo = document.createElement("div");
        gameInstance.logo.className = "logo " + gameInstance.Module.splashScreenStyle;
        gameInstance.container.appendChild(gameInstance.logo);
    }
    if (!gameInstance.progress) {
        gameInstance.progress = document.createElement("div");
        gameInstance.progress.className = "progress " + gameInstance.Module.splashScreenStyle;
        gameInstance.progress.empty = document.createElement("div");
        gameInstance.progress.empty.className = "empty";
        gameInstance.progress.appendChild(gameInstance.progress.empty);
        gameInstance.progress.full = document.createElement("div");
        gameInstance.progress.full.className = "full";
        gameInstance.progress.appendChild(gameInstance.progress.full);
        gameInstance.container.appendChild(gameInstance.progress);
    }
    gameInstance.progress.full.style.width = (100 * progress) + "%";
    gameInstance.progress.empty.style.width = (100 * (1 - progress)) + "%";
    FBInstant.setLoadingProgress(100 * progress);
    if (progress == 1) {
        FBInstant.startGameAsync().then(function () {
            game.start();
            console.log("Game Started");
        });

        gameInstance.logo.style.display = gameInstance.progress.style.display = "none";
    }
}
January 30 at 6:21 AM
Jack