Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

webgl canvas disables page scrolling

Discussion in 'Web' started by jesuislinus, Sep 20, 2017.

  1. jesuislinus

    jesuislinus

    Joined:
    Aug 1, 2017
    Posts:
    2
    hi,

    i've tried every possible solution i could find, but no success.

    i have unity animation running in a canvas on my page. when scrolling the page, scrolling stops when the mouse gets over the webgl content.

    Code (CSharp):
    1. #if !UNITY_EDITOR && UNITY_WEBGL
    2.     WebGLInput.captureAllKeyboardInput = true;
    3. #endif
    doesnt solve the problem, it only deals with keyboard input it seems. also i'm affraid the moment i find a solution, another problem might occur: i have a small script that animates the camera with a parallax effect based on the mouse coordinates.

    so ideally im looking for a solution that:

    a) passes scrolling to the webpage
    b) the webgl content still reads the mouse pointer coordinates

    if there is noo solution from withing unity, maybe someone knows a trick how to unbind scrolling from the webgl content by javascript?

    help is much appreciatet after hours of searching and trying:)

    thank you!
     
  2. jesuislinus

    jesuislinus

    Joined:
    Aug 1, 2017
    Posts:
    2
    ok, i solved it. for those who experience the same problem, this is one solution:
    style:
    #gameContainer{pointer-events:none; }

    html:
    <div id="gameContainer" ></div>

    webgl still reads the mouse coordinates, but ignores scroll and passes it on to the content below.
     
    sama-van likes this.
  3. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    This method seems to disable every control from the webGL, also disabling UI clicks...

    Did you manage to disable the mouse scroll only?... <_<..
     
  4. Peter-HappyVolcano

    Peter-HappyVolcano

    Joined:
    Dec 7, 2013
    Posts:
    2
    I have the same problem. I need mouse input in the webGL, but scrolling should scroll the webpage.

    Did you ever got a solution for this, sama-van?