Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[Need Help] Webgl build input position is incorrect/offset

Discussion in 'Editor & General Support' started by Lonyin_Chan, Aug 5, 2020.

  1. Lonyin_Chan

    Lonyin_Chan

    Joined:
    May 9, 2017
    Posts:
    4
    Here's my issue, in one of my scenes in my webgl build, when clicking on anything, the input position is wrong where if I want to click on a button, I have to somehow guess by clicking somewhere outside the button's 'input box'.

    Here's the build:
    https://iluvsnowlc.github.io/WebglTest/

    This issue only happens in chrome including for android and only happens on the second scene after clicking start. The first scene is all fine where the mouse cursor position seems to be correct. The editor view is also fine.

    I am using Unity 2019.4.6f1, it was upgraded several times to this version as this problem persisted in previous versions. Components such as canvas scaler, eventsystem and camera are the same in the first scene and second.

    Any help would be greatly appreciated!
     
  2. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
    Hi @chan_22,

    If the issue is happening on the second scene, but not in the first one, it seems that maybe is not reset properly.

    Have you tried to only include your second scene on the build and test it without the first scene?

    If not, would you mind trying?


    Thanks!
     
  3. Lonyin_Chan

    Lonyin_Chan

    Joined:
    May 9, 2017
    Posts:
    4
    Yes I have tried only building with second scene, the problem still persists only in chrome, it also happens even in the default webgl template.
     
  4. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
  5. akiyamae

    akiyamae

    Joined:
    Nov 30, 2020
    Posts:
    1
    Hi, there.

    Noob here, but I guess it might help giving another input on this issue.

    For me it only happens in android/chrome, but consistently, regardless of scene. Android/firefox seems to render just fine.

    My webgl-content div set at width: 100% and height: 100% caused the exact same issue. I've fixed it by setting the height to a fixed resolution (in my case 1200px).

    If my understanding is correct, chrome on android is unable to get the right height for the canvas and render the hit areas in a scaled position, even if they render graphically correct.

    Hope it helps!
     
  6. God0fMagic

    God0fMagic

    Joined:
    Feb 8, 2019
    Posts:
    16
    I second akiyamae. Unity 2019.4.28f1, setting width and height to 100% on android chrome makes button click area differ from visuals but works fine on adroid firefox