Search Unity

Event mousePosition suddenly not updating unless during mouse click

Discussion in 'Immediate Mode GUI (IMGUI)' started by ChristmasEve, Nov 19, 2018.

  1. ChristmasEve

    ChristmasEve

    Joined:
    Apr 21, 2015
    Posts:
    45
    I waited a while to upgrade to the latest version (2018.2.16). I was last using a 2017 release. To my dismay, something strange is now going on with the current event mousePosition function. I use windows within my GUI and, from within those windows' functions, I check for mouse clicks to perform certain actions. But some windows have mouse-over functionality so they're constantly polling the current event's mousePosition and checking if the mouse entered a rectangle (or left a rectangle), then I take the appropriate action such as displaying an item's details in a popup (or hiding it).

    Sometime in 2018, Unity introduced a bug where calls to Event.current.mousePosition from within my window functions will not reflect changes in the mouse position until a click is received. So the X and Y only reflect the position the mouse was at during the last mouse down or mouse up event. This only seems to be happening in my Mac OSX build. It doesn't happen in the editor and I have not tried a Windows build yet.

    To get around this, I resorted to polling Input.mousePosition to get the absolute mouse position, inverting Y, and subtracting the window's X/Y to get an approximation of what event.current.mousePosition should be. I hate having to do this. Does anyone know a more elegant way to solve this or if Unity plans on addressing it?

    These are the kinds of things that make me scared to upgrade. It seems that very few Unity updates are without new bugs that didn't exist before.

    Thanks in advance!
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Have you filled any bug reports?
     
  3. jonathangutman

    jonathangutman

    Joined:
    Dec 6, 2016
    Posts:
    5
    I have the exact same issue, but in windows builds. It started after upgrading to 2018.2 from 2018.1 and I havnt been able to find a solution for it.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    File a bug report please