Search Unity

Question which variable saves the loading progress of webgl?

Discussion in 'Web' started by uziiii2612195, Nov 16, 2021.

  1. uziiii2612195

    uziiii2612195

    Joined:
    Sep 26, 2021
    Posts:
    8
    upload_2021-11-16_17-34-5.png
    for example the program is loading 90%. how do i get that 90% in a variable .help
     
  2. MarcelPursche

    MarcelPursche

    Unity Technologies

    Joined:
    Mar 3, 2021
    Posts:
    45
    Hi,
    You can access the loading progress using the progress callback given to the UnityLoader in Javascript.
    You can create a custom template to modify the "index.html" to hook into that callback https://docs.unity3d.com/Manual/webgl-templates.html

    Code (JavaScript):
    1. createUnityInstance(canvas, config, (progress) => {
    2.      // Do something with progress variable here
    3.      // progress is within range [0,1]
    4.      progressBarFull.style.width = 100 * progress + "%";   }).then((unityInstance) => {
    5.       loadingBar.style.display = "none";
    6. }).catch((message) => {
    7.       alert(message);
    8. });