I don't have UnityLoader.Intantiate() in my index.html

I’ve found these websites Unity - Manual: WebGL graphics that explains about the Camera Clear behaviour in WebGL, and this post https://answers.unity.com/questions/1577204/unity-webgl-show-only-one-camera-when-use-multiple.html?childToView=1670624#answer-1670624. So I need to add that code to my project.

The problem is, I’m looking for the UnityLoader

UnityLoader.instantiate("unityContainer", "%UNITY_WEBGL_BUILD_URL%", {
    Module: {
        "webglContextAttributes": {"preserveDrawingBuffer": true},
    }
});

and there is none in the index.html file

I don’t know if the template is working fine, or maybe the documentation is not updated.

This is the javascript code attached to my index.html file

var buildUrl = "Build";
      var loaderUrl = buildUrl + "/BuildsWebGL.loader.js";
      var config = {
        dataUrl: buildUrl + "/BuildsWebGL.data",
        frameworkUrl: buildUrl + "/BuildsWebGL.framework.js",
        codeUrl: buildUrl + "/BuildsWebGL.wasm",
        streamingAssetsUrl: "StreamingAssets",
        companyName: "Visamalog",
        productName: "Tetris3D",
        productVersion: "0.2"
      };

      var container = document.querySelector("#unity-container");
      var canvas = document.querySelector("#unity-canvas");
      var loadingBar = document.querySelector("#unity-loading-bar");
      var progressBarFull = document.querySelector("#unity-progress-bar-full");
      var fullscreenButton = document.querySelector("#unity-fullscreen-button");

      if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
        container.className = "unity-mobile";
        config.devicePixelRatio = 1;
      } else {
        canvas.style.width = "960px";
        canvas.style.height = "600px";
      }
      loadingBar.style.display = "block";

      var script = document.createElement("script");
      script.src = loaderUrl;
      script.onload = () => {
        createUnityInstance(canvas, config, (progress) => {
          progressBarFull.style.width = 100 * progress + "%";
        
        }).then((unityInstance) => {
          loadingBar.style.display = "none";
          fullscreenButton.onclick = () => {
            unityInstance.SetFullscreen(1);
          };
        }).catch((message) => {
          alert(message);
        });
      };
      document.body.appendChild(script);

Apologies, that documentation page seems to be out of date since 2020.1 where this piece of code was refactored.

In the old code, the config parameter was the third argument to UnityLoader.instantiate(). In the new code, it is the second argument to createUnityInstance(). So you should be able to write

      var config = {
        dataUrl: buildUrl + "/BuildsWebGL.data",
        frameworkUrl: buildUrl + "/BuildsWebGL.framework.js",
        codeUrl: buildUrl + "/BuildsWebGL.wasm",
        streamingAssetsUrl: "StreamingAssets",
        companyName: "Visamalog",
        productName: "Tetris3D",
        productVersion: "0.2",
        webglContextAttributes: {"preserveDrawingBuffer": true},
      };

to implement this. Let me know how that goes?