index.html 4.4 KB

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