Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  3. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Event mousePosition suddenly not updating unless during mouse click

Discussion in 'Extensions & OnGUI' started by ChristmasEve, Nov 19, 2018.

  1. ChristmasEve

    ChristmasEve

    Joined:
    Apr 21, 2015
    Posts:
    23
    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:
    3,095
    Have you filled any bug reports?
     
  3. jonathangutman

    jonathangutman

    Joined:
    Dec 6, 2016
    Posts:
    4
    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:
    3,095
    File a bug report please