ContextDataUpdater overwrites value in context before a setter was initialized

Issue #77 resolved
Christian Oeing repo owner created an issue

When using a ComponentSingleSetter to set a context value to a UI element and a ComponentDataProvider + ContextDataUpdater to set a UI value to a context value (i.e. a two-way-binding), the ContextDataUpdater is executed first which means the context value is overwritten by the UI element value.

Instead the initial value should always be the context value.

This issue was reported in the forum: https://forum.unity.com/threads/released-data-bind-for-unity.298471/page-6#post-3488086

Comments (7)

  1. Christian Oeing reporter

    I was able to reproduce the issue with the normal ToggleIsOnProvider/Setter. It's again an issue with the initialization order. When the context changed while the game object with the ContextDataUpdater on it was already active, the setting of the context value was already delayed to the end of the frame to allow other scripts (e.g. the ToggleIsOnSetter) to initialize correctly. This didn't happen when first the context was setup and afterwards the game object with the logic on it was enabled. So I changed the behaviour in that location.

    If it shouldn't work with the synchronizer (which should be the best way when a two way binding is required), try replacing the attached files and hopefully that fixes the problem for you.

  2. Jan D

    ContextDataUpdater.cs needs to have this signature protected override void LateUpdate() otherwise it does not compile

  3. Christian Oeing reporter

    Oh, yeah, I changed that in another commit before to add a unit test for this bug.

  4. Log in to comment