Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Solved] EditorGUI ObjectField not working

Discussion in 'Immediate Mode GUI (IMGUI)' started by whileBreak, Jan 4, 2018.

  1. whileBreak

    whileBreak

    Joined:
    Aug 28, 2014
    Posts:
    289
    Hi, I have been having a problem, I'm working on a framework for the editor UI, its almost there but I'm having a problem that might be a bit too specific for just a simple answer, still I can't come with a solution but here is the problem.

    My GUI fields like ObjectField or ColorField are failing to update, the code is fine, the syntax x = ObjectField(x), is proper. But something is happening before that is interfering with the proper functioning of the field.

    I know where the problem is, and it might be related to a section of code that looks something like this.

    Code (CSharp):
    1. if(something)
    2.      GUI.BeginScroll();
    3. else
    4.       GUI.BeginGroup();
    5.  
    6.  
    7. //MY FIELD WOULD BE HERE
    8.  
    9. if(something)
    10.      GUI.EndScroll();
    11. else
    12.       GUI.EndGroup();
    Not sure if this is causing this.

    I do't understand why this might be happening, I would like to know whats going on here, why the Fields might be failing to update.
     
  2. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,307
    Maybe "something" is changing between the different states of the GUI?

    When does "something" change? You need to be careful that the GUI methods are the same through the "Layout" and "Repaint" events.
     
    whileBreak likes this.
  3. whileBreak

    whileBreak

    Joined:
    Aug 28, 2014
    Posts:
    289
    Oh man i know what it is, i have separated the UI into 2 phases, events and Paint. And on just one area those two are done different. I'll check how to fix it. Thanks for the input!
     
    CDF likes this.