Search Unity

Preventing "first frame default value flash" of BindableElement

Discussion in 'UI Toolkit' started by 5argon, Oct 6, 2021.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    When I design a bindable UXML, it has some default values. But since each element has binding path, they would all be replaced by the bound object.

    When I use it in my custom inspector, I load UXML, CloneTree(this), then finally .Bind(mySerializedObject). But the first frame I can see briefly the design-time value before it is controlled in the next frame.

    What can I do after binding to force the tree to change immediately rather than waiting for the next frame? I tried MarkDirtyRepaint, but it is the same, the method says it will repaint the next frame which would occur anyways due to having new binding value. I want the tree to change this frame after setting .Bind.

    Currently I manually change the tree using the binded value's fields but it is not generic, different UXML needs different solution just to fix its first frame.
     
  2. jonathanma_unity

    jonathanma_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    229
    Hi, from what you're describing this should not happen so this may be a bug but it's hard to tell without proper investigation. Could you report a bug (Help -> Report a Bug...) with a sample repro project?
     
    5argon likes this.