UnityProgress.js 1.2 KB

123456789101112131415161718192021222324
  1. function UnityProgress(unityInstance, progress) {
  2. if (!unityInstance.Module)
  3. return;
  4. if (!unityInstance.logo) {
  5. unityInstance.logo = document.createElement("div");
  6. unityInstance.logo.className = "logo " + unityInstance.Module.splashScreenStyle;
  7. unityInstance.container.appendChild(unityInstance.logo);
  8. }
  9. if (!unityInstance.progress) {
  10. unityInstance.progress = document.createElement("div");
  11. unityInstance.progress.className = "progress " + unityInstance.Module.splashScreenStyle;
  12. unityInstance.progress.empty = document.createElement("div");
  13. unityInstance.progress.empty.className = "empty";
  14. unityInstance.progress.appendChild(unityInstance.progress.empty);
  15. unityInstance.progress.full = document.createElement("div");
  16. unityInstance.progress.full.className = "full";
  17. unityInstance.progress.appendChild(unityInstance.progress.full);
  18. unityInstance.container.appendChild(unityInstance.progress);
  19. }
  20. unityInstance.progress.full.style.width = (100 * progress) + "%";
  21. unityInstance.progress.empty.style.width = (100 * (1 - progress)) + "%";
  22. if (progress == 1)
  23. unityInstance.logo.style.display = unityInstance.progress.style.display = "none";
  24. }