Search Unity

Incorrect position of moved utility editor window

Discussion in 'Immediate Mode GUI (IMGUI)' started by vividhelix, Feb 3, 2015.

  1. vividhelix

    vividhelix

    Joined:
    Mar 20, 2013
    Posts:
    78
    I'm trying to get the position of a utility editor window (EditorWindow.ShowUtility) but the returned position has x and y as zero unless the mouse moves away from the title bar (in which case the position gets correctly updated).

    I've included some logging in the Update() method of my EditorWindow subclass and it seems that this is what's happening:

    - window position reported correctly
    - start moving window by dragging its title bar
    - window position reported as having x=0 and y=0
    - if at this point the window is closed, the position remains the same (x=0, y=0)
    - if moving the mouse away from the title bar, position gets updated to the right value

    This looks like a bug, any ideas for a workaround?
     
  2. vividhelix

    vividhelix

    Joined:
    Mar 20, 2013
    Posts:
    78
    I ended up having a button inside the window and asking the user to click that button.
     
  3. GlitchedPolygons

    GlitchedPolygons

    Joined:
    Jun 18, 2013
    Posts:
    210
    I just submitted this bug (Case 977595), since it's still an issue and it would be nice if this was finally fixed.
    It's really annoying when you expect that getter to return a value and you just can't trust it.
     
  4. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    2019 and this is still an issue. I can't find the case on Google. @GlitchedPolygons , any chance you have a direct link?
     
  5. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    It turns out you can access the actual position reliably with reflection, using:

    Code (CSharp):
    1. window.m_Parent.window.position;
     
    GlitchedPolygons likes this.
  6. GlitchedPolygons

    GlitchedPolygons

    Joined:
    Jun 18, 2013
    Posts:
    210