main.html 4.6 KB

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