如何在屏幕Web gl unity上填充空白? [英] How do I fill white space on screen web gl unity?

查看:81
本文介绍了如何在屏幕Web gl unity上填充空白?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

空白图片

硬编码图像

所以我们正在制作此游戏,我希望游戏屏幕填充空白(我认为这就是使其成为原始分辨率?).

编码人员说容器只是被硬编码为一定大小",他不知道如何使所有计算机完全一致地填满屏幕,例如,如果计算机的分辨率不同.

该游戏是统一制作的,而那个家伙是在网络浏览器中说的.

对不起,谢谢您,这个网站的新手.

解决方案

您需要通过.

whitespace image

hardcoded image

so this game we are making i want the game screen to fill up the white space (i think this is called making it the native resolution?).

the coder says "the container is just hardcoded to a certain size" and he doesn't know how to make it fill up the screen pefectly consistently for all computers for example if computers have different resolutions.

the game is being made in unity and the guy said its in web gl.

sorry and thank you, new to this site.

解决方案

You need to make your own template by changing the HTML as documented here. You can choose either one of the defaults or create your own template.

According to those docs you create folder in Assets called WebGLTemplates and inside that create a new folder for your template like BetterTemplate. Inside that put an index.html file and any other images, css, JavaScript files you want included with your game.

The index.html could look something like this

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

Then you pick Edit->Project Settings->Player from the menus and under the WebGL tab choose your template

Here's an example that fills the window.

这篇关于如何在屏幕Web gl unity上填充空白?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆