如何在itch.io上增加Unity WebGL游戏窗口的大小?

问题描述 投票:1回答:1

我刚刚将我的第一个Unity WebGL版本上传到itch.io,但窗口很小,因此您只能看到实际游戏视图中心的一小部分

有问题的游戏,以及exe下载和公共仓库:https://lower-third.itch.io/blackbox

enter image description here

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 | 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>

CSS:

.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;}

[就像我说的那样,这是我第一次尝试使用这些东西,因此我不知道要更改哪个div以及要应用的CSS,并且还没有在网上找到任何适当的答案。我要做的就是将index.html文件中unityContainer的样式更改为1920x1080。这只是使我的游戏能够以更高的分辨率渲染,而不会改变游戏视图的大小,从而使视图变得更加无用。其他一切都与Unity为构建生成的一样。

供参考,我在此项目中使用URP和Unity 2019.3.0f6,但我怀疑这与我的问题有关系。我的浏览器中的游戏运行正常。我只想使窗口尽可能大,并确保它显示整个游戏。

html css unity3d unity-webgl
1个回答
0
投票

如果您使用itch.io游戏仪表板中的默认WebGL构建设置,则有一个自动检测选项。

solution

© www.soinside.com 2019 - 2024. All rights reserved.