index.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <!DOCTYPE html>
  2. <meta name="viewport"
  3. content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  4. <html lang="en-us">
  5. <head>
  6. <meta charset="utf-8">
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  8. <title>%UNITY_WEB_NAME%</title>
  9. <link rel="shortcut icon" href="TemplateData/favicon.ico">
  10. <link rel="stylesheet" href="TemplateData/style.css">
  11. <script src="TemplateData/UnityProgress.js"></script>
  12. <script type="text/javascript">
  13. function FitScreen() {
  14. console.log = console.info = console.warn = function() {};
  15. var w = %UNITY_WIDTH%;
  16. var h = %UNITY_HEIGHT%;
  17. var availWidth = window.innerWidth;
  18. var availHeight = window.innerHeight;
  19. var canvas = document.getElementById("#canvas");
  20. /**
  21. //按比例调节
  22. if (availWidth / availHeight > w / h) {
  23. height = availHeight;
  24. width = (height * w / h);
  25. } else {
  26. width = availWidth;
  27. height = width * h / w;
  28. }
  29. */
  30. height = availHeight;
  31. width = availWidth;
  32. document.getElementById("unityContainer").style.width = width + "px";
  33. document.getElementById("unityContainer").style.height = height + "px";
  34. canvas.style.width = "100%";
  35. canvas.style.height = "100%";
  36. if (window.WEBAudioMute) {
  37. window.WEBAudioMute(false);
  38. }
  39. }
  40. function mute() {
  41. if (window.WEBAudioMute) {
  42. window.WEBAudioMute(true);
  43. }
  44. }
  45. </script>
  46. <script src="%UNITY_WEBGL_LOADER_URL%"></script>
  47. <script>
  48. var unityInstance = UnityLoader.instantiate("unityContainer", "%UNITY_WEBGL_BUILD_URL%", {onProgress: UnityProgress});
  49. </script>
  50. </head>
  51. <body onFocus="FitScreen();" onLoad="FitScreen();" onResize="FitScreen();" onblur="mute();">
  52. <div class="webgl-content" id="unityContainer" style="width: %UNITY_WIDTH%px; height: %UNITY_HEIGHT%px" ></div>
  53. </body>
  54. </html>