index.html 4.5 KB

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