Unity打包H5 网页全屏

修改unity打包后的Webgl的H5代码

unity 2019


    
"webgl-content">
"unityContainer" style="width: 1900px; height: 960px">
`

修改为

"no" style="overflow-y:hidden">
    
"webgl-content" style="width: 100%; height: 100%">
"unityContainer" style="width: 100%; height: 100%;

unity 2021

1修改下面部分

<div id="unity-container" style="width: 100%;height:100%">
      <canvas id="unity-canvas" width=auto height=auto>canvas>

2、修改
canvas.style.width = “1900px”;
canvas.style.height = “900px”;

canvas.style.width = “100%”;
canvas.style.height = “100%”;

 if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
        // Mobile device style: fill the whole browser client area with the game canvas:

        var meta = document.createElement('meta');
        meta.name = 'viewport';
        meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
        document.getElementsByTagName('head')[0].appendChild(meta);
        container.className = "unity-mobile";
        canvas.className = "unity-mobile";

        // To lower canvas resolution on mobile devices to gain some
        // performance, uncomment the following line:
        // config.devicePixelRatio = 1;

        unityShowBanner('WebGL builds are not supported on mobile devices.');
      } else {
        // Desktop style: Render the game canvas in a window that can be maximized to fullscreen:

        canvas.style.width = "100%";
        canvas.style.height = "100%";
      }

你可能感兴趣的:(unity,html5)