1. 程式人生 > >Unity3D生成的WebGL自適應螢幕

Unity3D生成的WebGL自適應螢幕

<!DOCTYPE html>
<html lang="en-us">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Unity WebGL Player | First</title>
    <link rel="shortcut icon" href="TemplateData/favicon.ico">
    <link rel="stylesheet" href="TemplateData/style.css">
    <script src="TemplateData/UnityProgress.js"></script>  
    <script src="Build/UnityLoader.js"></script>
    <script>
      var gameInstance = UnityLoader.instantiate("gameContainer", "Build/aa.json", {onProgress: UnityProgress});
         function Reset() {
 var canvas = document.getElementById("#canvas");
canvas.height= document.documentElement.clientHeight;
 canvas.width = document.documentElement.clientWidth;
console.log(canvas.width );
 }
 
    </script>
  </head>
  <body onload="Reset()" onresize="Reset()" >
    <div class="webgl-content"  style="width: 100%; height: 100%">
      <div id="gameContainer" style="width: 100%; height: 100%"></div>
      
    </div>
  </body>
</html>