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 is getting mouse position only on mouse move

Discussion in 'Scripting' started by programicks, Apr 9, 2020.

  1. programicks

    programicks

    Joined:
    Sep 5, 2014
    Posts:
    11
    Hi.

    When I get the mouse position using Input.mousePosition, I can get this position when playing within Unity itself but when I publish to webgl, the mouse position only works on mouse move.

    The problem with this is, I have a plane with texture I use as a mouse cursor that moves in the mouse position and if a player moves their mouse into where the webgl is displayed in the web page while webgl is loading then the cursor image won’t show until I move the mouse once game has loaded.

    I hide the normal cursor at the start so nothing shows until I move the mouse and then the cursor image.

    I would rather not show the normal cursor then the image cursor on mouse move.

    Is there a way to get Input.mousePosition the very first time a game loads and runs without first moving the mouse? Doesn’t work in void start, awake, ongui or update.

    Cheers.