You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.2 KiB

  1. <!DOCTYPE html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
  6. <title>%UNITY_WEB_NAME%</title>
  7. <style>
  8. html {
  9. box-sizing: border-box;
  10. }
  11. *, *:before, *:after {
  12. box-sizing: inherit;
  13. }
  14. body {
  15. margin: 0;
  16. background: #444;
  17. }
  18. #gameContainer {
  19. width: 100vw;
  20. height: 100vh;
  21. }
  22. canvas {
  23. width: 100%;
  24. height: 100%;
  25. display: block;
  26. }
  27. /* try to handle mobile dialog */
  28. canvas + * {
  29. z-index: 2;
  30. }
  31. .logo {
  32. display: block;
  33. max-width: 100vw;
  34. max-height: 70vh;
  35. }
  36. .progress {
  37. margin: 1.5em;
  38. border: 1px solid white;
  39. width: 50vw;
  40. display: none;
  41. }
  42. .progress .full {
  43. margin: 2px;
  44. background: white;
  45. height: 1em;
  46. transform-origin: top left;
  47. }
  48. #loader {
  49. position: absolute;
  50. left: 0;
  51. top: 0;
  52. width: 100vw;
  53. height: 100vh;
  54. display: flex;
  55. flex-direction: column;
  56. align-items: center;
  57. justify-content: center;
  58. }
  59. .spinner,
  60. .spinner:after {
  61. border-radius: 50%;
  62. width: 5em;
  63. height: 5em;
  64. }
  65. .spinner {
  66. margin: 10px;
  67. font-size: 10px;
  68. position: relative;
  69. text-indent: -9999em;
  70. border-top: 1.1em solid rgba(255, 255, 255, 0.2);
  71. border-right: 1.1em solid rgba(255, 255, 255, 0.2);
  72. border-bottom: 1.1em solid rgba(255, 255, 255, 0.2);
  73. border-left: 1.1em solid #ffffff;
  74. transform: translateZ(0);
  75. animation: spinner-spin 1.1s infinite linear;
  76. }
  77. @keyframes spinner-spin {
  78. 0% {
  79. transform: rotate(0deg);
  80. }
  81. 100% {
  82. transform: rotate(360deg);
  83. }
  84. }
  85. </style>
  86. </head>
  87. <body>
  88. <div id="gameContainer"></div>
  89. <div id="loader">
  90. <img class="logo" src="logo.png">
  91. <div class="spinner"></div>
  92. <div class="progress"><div class="full"></div></div>
  93. </div>
  94. </body>
  95. <script src="%UNITY_WEBGL_LOADER_URL%"></script>
  96. <script>
  97. if (UnityLoader.SystemInfo.mobile)
  98. {
  99. window.location.replace("http://www.google.com");
  100. }
  101. var gameInstance = UnityLoader.instantiate("gameContainer", "%UNITY_WEBGL_BUILD_URL%", {onProgress: UnityProgress});
  102. function UnityProgress(gameInstance, progress) {
  103. if (!gameInstance.Module) {
  104. return;
  105. }
  106. const loader = document.querySelector("#loader");
  107. if (!gameInstance.progress) {
  108. const progress = document.querySelector("#loader .progress");
  109. progress.style.display = "block";
  110. gameInstance.progress = progress.querySelector(".full");
  111. loader.querySelector(".spinner").style.display = "none";
  112. }
  113. gameInstance.progress.style.transform = `scaleX(${progress})`;
  114. if (progress === 1 && !gameInstance.removeTimeout) {
  115. gameInstance.removeTimeout = setTimeout(function() {
  116. loader.style.display = "none";
  117. }, 2000);
  118. }
  119. }
  120. </script>
  121. </html>