Search Unity

Bug Changing the resolution of the Canvas on HTML in WebGL makes the game screen smaller.

Discussion in 'Web' started by K_Kuriyama, Apr 13, 2023.

  1. K_Kuriyama

    K_Kuriyama

    Joined:
    Jul 4, 2020
    Posts:
    66
    Is this problem recurring?

    https://forum.unity.com/threads/can...using-linear-color-space.508476/#post-3319251


    In Unity 2022.2.13, when I change the resolution of the Canvas using canvas.width,canvas.height, it appears smaller in the lower left corner of the Canvas when I increase the resolution, as in my previous post, and when I decrease the resolution, the screen is not visible.

    As per previous posts, I have tried every combination of Liner, Gamma, HDR, and MSAA settings, but this problem has not been resolved at all.

    Code (JavaScript):
    1. mergeInto(LibraryManager.library, {
    2.     SetCanvasResolution: function (width, height) {
    3.         var canvas = document.getElementById("unity-canvas");
    4.         canvas.width = width;
    5.         canvas.height = height;
    6.     },
    7. });
     

    Attached Files:

  2. K_Kuriyama

    K_Kuriyama

    Joined:
    Jul 4, 2020
    Posts:
    66
    It was able to resolve itself!
    All I had to do was comment out the following code contained in index.html

    Code (JavaScript):
    1.       // config.matchWebGLToCanvasSize = false;