Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

*bizarre* Editor text fields sharing contents

Discussion in 'Immediate Mode GUI (IMGUI)' started by Aubrey-Falconer, Aug 7, 2009.

  1. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    438
    This is hard to explain, so I have captured a screencast of it:
    http://screencast.com/t/tavwy7AmtO

    Complete source code for the culprit editor script is available @:
    http://www.unifycommunity.com/wiki/index.php?title=Whirld

    As you can see in the screencast, the text fields in my editorwindow are somehow getting mixed up with each other in Unity's GUI system - rendering my window practically unusable... Hopefully someone can find something wrong that I am doing in my code, because otherwise there is a MAJOR bug in the editor GUI system!

    -Aubrey
     
  2. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    I have noticed in my app the same kind of thing happens. Whenever I press a button it seems the last variable I used (or something) is placed inside the first text field I go to (or the last one to have focus before I pressed the button)

    This issue is resolved by clicking into another text field. For some reason, saying (pseudo code here) variablex = IntField(x) doesn't assing variablex the value shown in the field until you modify that field. The value that is displayed in that box only SHOWS in the box, but is not the value of the variable in that box... Perhaps Unity only assigns the values when the values change, but looking at the code above x=x, there is no mention of x = (x if x != x) so this behavior is a bit strange to me...

    Click in another text field and voila, the box in question's value is blank again. But!!! If you press even an arrow button on the field you WILL assign that value to the field. It looks like a copy-paste operation with the pasted value hovering over the field just waiting to be accepted...

    In my app that is not so much of an issue so I didn't try to solve that issue yet, but try doing this, just as an idea... When you press the button, see what the value is that shows up in your field. Figure out what variable HAD that value and then change the code in the button so that the LAST thing it does is change that variable's value to blank. This way, if the box uses the last value in that variable then it should be reset to blanks okay, but if it takes the value that was in the variable BEFORE the button code started to execute then I would consider this a bug in Unity...
     
  3. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    438
    Very interesting. I have expanded the contents of my panel significantly, and it now seems to be working better. I think that much of the issue is centered on the GUI system reverting to some kind of "cached" state for a panel whenever it looses focus instead of always redrawing it to get the latest version.