按照默认设置,发布webgl后,代码如下(发布好的文件,根目录index.html文件)
<!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 | Domo</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 unityInstance = UnityLoader.instantiate("unityContainer", "Build/Demo1.json", {onProgress: UnityProgress});
</script>
</head>
<body>
<div class="webgl-content">
<div id="unityContainer" style="width: 960px; height: 600px"></div>
<div class="footer">
<div class="webgl-logo"></div>
<div class="fullscreen" onclick="unityInstance.SetFullscreen(1)"></div>
<div class="title">Domo</div>
</div>
</div>
</body>
</html>
修改Body中这一句代码
<div id="unityContainer" style="width: 960px; height: 600px"></div>
为
<div id="unityContainer" style="width: 99vw; height: 95vh;"></div>
这里面,修改后的宽高值为,窗口占浏览器的比例。
width: 99vw 即在左右留一白边。
height: 95vh 设置为95可以正好将网页底端,显示项目名和Logo那一部分显示出来。