index.html 4.7 KB

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