Html 如何在itch.io上增加Unity WebGL游戏窗口的大小?
我刚刚将我的第一个Unity WebGL构建上传到itch.io,但窗口非常小,因此您只能看到实际游戏视图中心的一小部分 有问题的游戏,以及exe下载和公共回购: HTML: 就像我说的,这是我第一次尝试使用这些东西,所以我不知道要更改什么div,应用什么css,并且还没有在网上找到任何合适的答案。我所做的只是将index.html文件中unityContainer的样式更改为1920x1080。这只是使我的游戏呈现在一个更大的分辨率,而不改变在瘙痒游戏视图的大小,使视图更无用。其他一切都是为构建生成的统一Html 如何在itch.io上增加Unity WebGL游戏窗口的大小?,html,css,unity3d,unity-webgl,Html,Css,Unity3d,Unity Webgl,我刚刚将我的第一个Unity WebGL构建上传到itch.io,但窗口非常小,因此您只能看到实际游戏视图中心的一小部分 有问题的游戏,以及exe下载和公共回购: HTML: 就像我说的,这是我第一次尝试使用这些东西,所以我不知道要更改什么div,应用什么css,并且还没有在网上找到任何合适的答案。我所做的只是将index.html文件中unityContainer的样式更改为1920x1080。这只是使我的游戏呈现在一个更大的分辨率,而不改变在瘙痒游戏视图的大小,使视图更无用。其他一切都是为
作为参考,我在这个项目中使用了URP和Unity 2019.3.0f6,但我怀疑这与我的问题有任何关系。游戏在我的浏览器中运行良好。我只想使窗口尽可能大,并确保它显示整个游戏。如果您使用itch.io游戏仪表板中的默认WebGL构建设置,则会显示一个自动检测选项
如果您使用itch.io游戏仪表板中的默认WebGL构建设置,则会有一个自动检测选项
这是否回答了您的问题,另外,如果你有完整的库存设置,你可以从itch.io上的游戏面板自动检测画布的大小。最终解决了这个问题这能回答你的问题吗,另外,如果你有完整的库存设置,你可以从itch.io上的游戏面板自动检测画布的大小。最终解决了这个问题。
<!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 | BlackBox</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/WebGL.json", { onProgress: UnityProgress });
</script>
</head>
<body>
<div class="webgl-content">
<div id="unityContainer" style="width: 1920px; height: 1080px"></div>
<div class="footer">
<div class="webgl-logo"></div>
<div class="fullscreen" onclick="unityInstance.SetFullscreen(1)"></div>
<div class="title">BlackBox</div>
</div>
</div>
</body>
</html>
.webgl-content * {border: 0; margin: 0; padding: 0}
.webgl-content {position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
.webgl-content .logo, .progress {position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
.webgl-content .logo {background: url('progressLogo.Light.png') no-repeat center / contain; width: 154px; height: 130px;}
.webgl-content .progress {height: 18px; width: 141px; margin-top: 90px;}
.webgl-content .progress .empty {background: url('progressEmpty.Light.png') no-repeat right / cover; float: right; width: 100%; height: 100%; display: inline-block;}
.webgl-content .progress .full {background: url('progressFull.Light.png') no-repeat left / cover; float: left; width: 0%; height: 100%; display: inline-block;}
.webgl-content .logo.Dark {background-image: url('progressLogo.Dark.png');}
.webgl-content .progress.Dark .empty {background-image: url('progressEmpty.Dark.png');}
.webgl-content .progress.Dark .full {background-image: url('progressFull.Dark.png');}
.webgl-content .footer {margin-top: 5px; height: 38px; line-height: 38px; font-family: Helvetica, Verdana, Arial, sans-serif; font-size: 18px;}
.webgl-content .footer .webgl-logo, .title, .fullscreen {height: 100%; display: inline-block; background: transparent center no-repeat;}
.webgl-content .footer .webgl-logo {background-image: url('webgl-logo.png'); width: 204px; float: left;}
.webgl-content .footer .title {margin-right: 10px; float: right;}
.webgl-content .footer .fullscreen {background-image: url('fullscreen.png'); width: 38px; float: right;}