Boxgroup doesn't update values in Update

Issue #40 wontfix
Matthew Smith 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. Bjarke Elias

    Thanks for reporting. I've been unable to replicate it myself though.

    What version of Odin and Unity are you using? And could provide the steps to replicate the issue?

  2. Matthew Smith 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.

  3. Bjarke Elias

    Yeah, that would be really helpful.

    Is it the inspector window not repainting? (Does it update if you click anywhere in the inspector to force an update, or does it actually show it inaccurately?)

  4. Matthew Smith 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).

  5. Matthew Smith 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!

  6. Bjarke Elias

    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.

  7. Bjarke Elias

    Changes made to non-serialized properties outside of the Inspector does not trigger any repaints. This could be fixed by tracking changes on non-serialized values.

  8. 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.

  9. Log in to comment