Boxgroup doesn't update values in Update

Issue #40 wontfix
MatthewS
created an issue

When using a Box group to group my variables - any variables that are changing in the Update call are not accurately shown in the inspector, and would only change in seperate function calls.

Changing this to tab group works fine.

Comments (10)

  1. MatthewS reporter

    I'm on Unity 5.6.0f3, and using Odin 0.9.0.3.

    Would it help if I uploaded the script? I've had to change it a bit to make it work, but changing it back to how it was shouldn't be too much of an issue (if that's easier for you?)

    Edit : Not a particularly complex script, it was a state machine tracking mouse movements.

  2. MatthewS reporter

    Sorry, have only just seen this. I will try recreate the script shortly!

    It was supposed to be tracking (and showing me) the mouse position when the mouse button was held down - however, it would only ever update those values when the state changed (on mouse down / up).

    The actual code itself was fine as when checking through Debug.Log the correct values were output - it was just not displaying on the Inspector box group.

    (Just about to head for lunch but will knock something up when I get back).

  3. MatthewS reporter

    Just recreated the script and it doesn't seem to be happening - I'll continue to have a play around and see if I can break it again.. But it definitely fixed by changing to TabGroup!

  4. Bjarke Elias Clauson-Kaas Ørrild

    Interesting! Thanks for the update, think I've figured it out.

        public Vector2 TriggersGUIRepaint; // Serialized
    
        [NonSerialized, ShowInInspector]
        public Vector2 DoesNotTriggerGUIRepaint;
    
        private void Update()
        {
            if (Input.GetMouseButton(0))
            {
                this.TriggersGUIRepaint = Input.mousePosition;
            }
            else
            {
                this.DoesNotTriggerGUIRepaint = Input.mousePosition;
            }
        }
    

    Unity automatically triggers a GUI repaint in the inspector, if any of its serialized properties have been changed, however since the DoesNotTriggerGUIRepaint is not being serialized, unity doesn't detect any changes.

    The real issue here is that it actually works when a TabGroup is present, which means something is triggering GUIRepaint all the time 😄

    To get around this for now you can add this script to your class:

    #if UNITY_EDITOR
    
        [OnInspectorGUI]
        private void OnInspectorGUI()
        {
            Sirenix.Utilities.Editor.GUIHelper.RequestRepaint();
        }
    
    #endif
    

    I'll get back to this issue later. Would be nice if we could detect these changes and update the GUI, as people would expect it to.

  5. Tor Esa Vestergaard

    This simply isn't feasible given Unity's design. If you wish the inspector to constantly update, you must manually force an inspector repaint every time you change said values in Update, as we cannot detect this change without a prohibitive performance cost.

  6. Log in to comment