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.

Input position relative to canvas in webgl

Discussion in 'Project Tiny' started by exoainteractive, Jan 22, 2021.

  1. exoainteractive


    Jan 21, 2017
    In the examples InputSystem::GetInputPosition() is used to get the position of the mouse. In webgl that position given is relative to the browser page, but we would need to have the mouse position in the canvas coordinates instead for the cases where the canvas is not fullscreen.

    In the example attached, P0 at the bottom left of the canvas should be (0;0) but it's (100;-100) and P1 should be (300;300) but it's (400;200), so basically the position of the canvas inside the page is not taken into account.

    Thanks for your help!

    Attached Files:

    Last edited: Jan 22, 2021