如何在屏幕 webgl 统一上填充白色 space?
How do I fill white space on screen web gl unity?
白色space图片
硬编码图像
所以我们正在制作的这款游戏我希望游戏屏幕填满白色 space(我认为这就是所谓的使其成为 原始分辨率 ?)。
编码员说 "the container is just hardcoded to a certain size" 并且他不知道如何让它完美一致地填满所有计算机的屏幕,例如,如果计算机具有不同的分辨率。
游戏是在 unity 中制作的,那家伙说是在 web gl 中。
对不起,谢谢你,这个网站的新手。
您需要通过changing the HTML as documented here制作您自己的模板。您可以选择其中一个默认模板或创建自己的模板。
根据这些文档,您在 Assets
中创建了名为 WebGLTemplates
的文件夹,并在其中为您的模板创建了一个新文件夹,例如 BetterTemplate
。在里面放一个 index.html
文件和任何其他图像,css,JavaScript 您想要包含在游戏中的文件。
index.html 可能看起来像这样
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>%UNITY_WEB_NAME%</title>
<style>
body { margin: 0; }
#gameContainer { width: 100vw; height: 100vh; }
canvas { width: 100%; height: 100%; }
</style>
<script src="Build/UnityLoader.js"></script>
<script>
var gameInstance = UnityLoader.instantiate("gameContainer", "Build/dist.json");
</script>
</head>
<body>
<div id="gameContainer"></div>
</body>
</html>
然后从菜单中选择“编辑”->“项目设置”->“播放器”,然后在“WebGL”选项卡下选择您的模板
白色space图片
硬编码图像
所以我们正在制作的这款游戏我希望游戏屏幕填满白色 space(我认为这就是所谓的使其成为 原始分辨率 ?)。
编码员说 "the container is just hardcoded to a certain size" 并且他不知道如何让它完美一致地填满所有计算机的屏幕,例如,如果计算机具有不同的分辨率。
游戏是在 unity 中制作的,那家伙说是在 web gl 中。
对不起,谢谢你,这个网站的新手。
您需要通过changing the HTML as documented here制作您自己的模板。您可以选择其中一个默认模板或创建自己的模板。
根据这些文档,您在 Assets
中创建了名为 WebGLTemplates
的文件夹,并在其中为您的模板创建了一个新文件夹,例如 BetterTemplate
。在里面放一个 index.html
文件和任何其他图像,css,JavaScript 您想要包含在游戏中的文件。
index.html 可能看起来像这样
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>%UNITY_WEB_NAME%</title>
<style>
body { margin: 0; }
#gameContainer { width: 100vw; height: 100vh; }
canvas { width: 100%; height: 100%; }
</style>
<script src="Build/UnityLoader.js"></script>
<script>
var gameInstance = UnityLoader.instantiate("gameContainer", "Build/dist.json");
</script>
</head>
<body>
<div id="gameContainer"></div>
</body>
</html>
然后从菜单中选择“编辑”->“项目设置”->“播放器”,然后在“WebGL”选项卡下选择您的模板