index.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <!DOCTYPE html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>Maze</title>
  7. <link rel="shortcut icon" href="TemplateData/favicon.ico">
  8. <link rel="stylesheet" href="TemplateData/style.css">
  9. </head>
  10. <body>
  11. <div id="unity-container" class="unity-desktop">
  12. <canvas id="unity-canvas" tabindex="-1"></canvas>
  13. <div id="unity-loading-bar">
  14. <div id="unity-progress-bar-empty">
  15. <div id="unity-progress-bar-full"></div>
  16. </div>
  17. </div>
  18. <div id="unity-warning"> </div>
  19. <div id="unity-footer">
  20. <div id="unity-fullscreen-button"></div>
  21. <div id="unity-build-title">Maze</div>
  22. </div>
  23. </div>
  24. <script>
  25. window.getQueryVariable = function getQueryVariable(variable) {
  26. var query = window.location.search.substring(1);
  27. var vars = query.split("&");
  28. for (var i = 0; i < vars.length; i++) {
  29. var pair = vars[i].split("=");
  30. if (pair[0] == variable) {
  31. return pair[1];
  32. }
  33. }
  34. return false;
  35. }
  36. var container = document.querySelector("#unity-container");
  37. var canvas = document.querySelector("#unity-canvas");
  38. var loadingBar = document.querySelector("#unity-loading-bar");
  39. var progressBarFull = document.querySelector("#unity-progress-bar-full");
  40. var fullscreenButton = document.querySelector("#unity-fullscreen-button");
  41. var warningBanner = document.querySelector("#unity-warning");
  42. // Shows a temporary message banner/ribbon for a few seconds, or
  43. // a permanent error message on top of the canvas if type=='error'.
  44. // If type=='warning', a yellow highlight color is used.
  45. // Modify or remove this function to customize the visually presented
  46. // way that non-critical warnings and error messages are presented to the
  47. // user.
  48. function unityShowBanner(msg, type) {
  49. function updateBannerVisibility() {
  50. warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
  51. }
  52. var div = document.createElement('div');
  53. div.innerHTML = msg;
  54. warningBanner.appendChild(div);
  55. if (type == 'error') div.style = 'background: red; padding: 10px;';
  56. else {
  57. if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
  58. setTimeout(function() {
  59. warningBanner.removeChild(div);
  60. updateBannerVisibility();
  61. }, 5000);
  62. }
  63. updateBannerVisibility();
  64. }
  65. var buildUrl = "Build";
  66. var loaderUrl = buildUrl + "/H5Game-ChinaSecuritiesMuseumMaze_WithBGM.loader.js";
  67. var config = {
  68. dataUrl: buildUrl + "/H5Game-ChinaSecuritiesMuseumMaze_WithBGM.data.unityweb",
  69. frameworkUrl: buildUrl + "/H5Game-ChinaSecuritiesMuseumMaze_WithBGM.framework.js.unityweb",
  70. codeUrl: buildUrl + "/H5Game-ChinaSecuritiesMuseumMaze_WithBGM.wasm.unityweb",
  71. streamingAssetsUrl: "StreamingAssets",
  72. companyName: "4dkk",
  73. productName: "Maze",
  74. productVersion: "0.1",
  75. showBanner: unityShowBanner,
  76. };
  77. // By default, Unity keeps WebGL canvas render target size matched with
  78. // the DOM size of the canvas element (scaled by window.devicePixelRatio)
  79. // Set this to false if you want to decouple this synchronization from
  80. // happening inside the engine, and you would instead like to size up
  81. // the canvas DOM size and WebGL render target sizes yourself.
  82. // config.matchWebGLToCanvasSize = false;
  83. if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
  84. // Mobile device style: fill the whole browser client area with the game canvas:
  85. var meta = document.createElement('meta');
  86. meta.name = 'viewport';
  87. meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
  88. document.getElementsByTagName('head')[0].appendChild(meta);
  89. container.className = "unity-mobile";
  90. canvas.className = "unity-mobile";
  91. // To lower canvas resolution on mobile devices to gain some
  92. // performance, uncomment the following line:
  93. // config.devicePixelRatio = 1;
  94. }
  95. loadingBar.style.display = "block";
  96. var script = document.createElement("script");
  97. script.src = loaderUrl;
  98. script.onload = () => {
  99. createUnityInstance(canvas, config, (progress) => {
  100. progressBarFull.style.width = 100 * progress + "%";
  101. }).then((unityInstance) => {
  102. loadingBar.style.display = "none";
  103. fullscreenButton.onclick = () => {
  104. unityInstance.SetFullscreen(1);
  105. };
  106. }).catch((message) => {
  107. alert(message);
  108. });
  109. };
  110. document.body.appendChild(script);
  111. </script>
  112. </body>
  113. </html>