Search Unity

Input.mousePosition is wrong on first click into Game Window

Discussion in 'Immediate Mode GUI (IMGUI)' started by tango209, Jan 24, 2015.

  1. tango209

    tango209

    Joined:
    Feb 23, 2011
    Posts:
    379
    I've searched, but can't find a solution to my problem.

    It appears that once the focus leaves the Game Window that Input.mousePosition stops updating, which I can kind of understand. The problem is that when you click back into the Game Window it does not use the position you just clicked on, but the position that was click that took it out of the Game Window.

    So, I'm trying to find a way to determine that first click back into the Game Window so I can ignore it in my EditorWindow's Update() method.
     
  2. Immanuel-Scholz

    Immanuel-Scholz

    Joined:
    Jun 8, 2013
    Posts:
    221
    Yea, I observed the same behaviour and I think its just a bug. Wasn't really annoying enough for me to file a bug report, but just go ahead and report one. ;)
     
  3. tango209

    tango209

    Joined:
    Feb 23, 2011
    Posts:
    379
    Yeah, I ended up just moving the functionality to a Custom Inspector and it works fine. Another problem with the Editor Window is that the mousePosition seems to jump around. Meaning if I move the mouse up and down between a range, say 100 to 200, I'll get readings outside of that range. I'll post a bug report when I get a chance.