Advertisement
annstasi

Сборка смены цвета круга WebGL, Edit -> PS -> Player -> Compression Disabled

May 9th, 2022
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.61 KB | None | 0 0
  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 | WebGLTest</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" width=960 height=600></canvas>
  13. <div id="unity-loading-bar">
  14. <div id="unity-logo"></div>
  15. <div id="unity-progress-bar-empty">
  16. <div id="unity-progress-bar-full"></div>
  17. </div>
  18. </div>
  19. <div id="unity-warning"> </div>
  20. <div id="unity-footer">
  21. <div id="unity-webgl-logo"></div>
  22. <div id="unity-fullscreen-button"></div>
  23. <div id="unity-build-title">WebGLTest</div>
  24. </div>
  25. </div>
  26. <script>
  27. var container = document.querySelector("#unity-container");
  28. var canvas = document.querySelector("#unity-canvas");
  29. var loadingBar = document.querySelector("#unity-loading-bar");
  30. var progressBarFull = document.querySelector("#unity-progress-bar-full");
  31. var fullscreenButton = document.querySelector("#unity-fullscreen-button");
  32. var warningBanner = document.querySelector("#unity-warning");
  33.  
  34. // Shows a temporary message banner/ribbon for a few seconds, or
  35. // a permanent error message on top of the canvas if type=='error'.
  36. // If type=='warning', a yellow highlight color is used.
  37. // Modify or remove this function to customize the visually presented
  38. // way that non-critical warnings and error messages are presented to the
  39. // user.
  40. function unityShowBanner(msg, type) {
  41. function updateBannerVisibility() {
  42. warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
  43. }
  44. var div = document.createElement('div');
  45. div.innerHTML = msg;
  46. warningBanner.appendChild(div);
  47. if (type == 'error') div.style = 'background: red; padding: 10px;';
  48. else {
  49. if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
  50. setTimeout(function() {
  51. warningBanner.removeChild(div);
  52. updateBannerVisibility();
  53. }, 5000);
  54. }
  55. updateBannerVisibility();
  56. }
  57.  
  58. var buildUrl = "Build";
  59. var loaderUrl = buildUrl + "/buildproject.loader.js";
  60. var config = {
  61. dataUrl: buildUrl + "/buildproject.data",
  62. frameworkUrl: buildUrl + "/buildproject.framework.js",
  63. codeUrl: buildUrl + "/buildproject.wasm",
  64. streamingAssetsUrl: "StreamingAssets",
  65. companyName: "DefaultCompany",
  66. productName: "WebGLTest",
  67. productVersion: "0.1",
  68. showBanner: unityShowBanner,
  69. };
  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.  
  78. if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
  79. container.className = "unity-mobile";
  80. // Avoid draining fillrate performance on mobile devices,
  81. // and default/override low DPI mode on mobile browsers.
  82. config.devicePixelRatio = 1;
  83. unityShowBanner('WebGL builds are not supported on mobile devices.');
  84. } else {
  85. canvas.style.width = "960px";
  86. canvas.style.height = "600px";
  87. }
  88. loadingBar.style.display = "block";
  89.  
  90. var script = document.createElement("script");
  91. script.src = loaderUrl;
  92. script.onload = () => {
  93. createUnityInstance(canvas, config, (progress) => {
  94. progressBarFull.style.width = 100 * progress + "%";
  95. }).then((unityInstance) => {
  96. // новая строка ниже !!!
  97. window.unityInstance = unityInstance;
  98. loadingBar.style.display = "none";
  99. fullscreenButton.onclick = () => {
  100. unityInstance.SetFullscreen(1);
  101. };
  102. }).catch((message) => {
  103. alert(message);
  104. });
  105. };
  106. document.body.appendChild(script);
  107.  
  108. </script>
  109. <div style="border: solid 2px black; width: 50 px; height: 40px; text-align:center" onclick="unityInstance.SendMessage('JShook','TintSphere')">Сменить цвет</div>
  110. </body>
  111. </html>
  112.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement