Dirty GUI using linkWithMesh

Hi there, and Happy New Year!!
Consider this PG: https://playground.babylonjs.com/#FX4EEA#4

I make a simple text inside a rectangle and then attached to a mesh with linkWithMesh.
As you can see the GUI seems dirty. If i comment out linkWithMesh all work fine.
Any idea?

Hi and Happy New Year to you,
Just like that, it looks to me like the GUI is not finished building when the scene renders.
Simply resizing the canvas makes the artefact go.

I took out all classes staff, but it didn’t work anyway.

Is the GUI creation right?
let gui = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI",true,scene);
I’ve always used it like that.

It seems there’s a refresh bug as this example from the doc does not work either:

It does work in 4.2.1, though. We need to investigate.

2 Likes

doesn’t look wrong to me.
I was rather thinking about delaying the scene creation but this new PG is kind of weird.
I can now see @Evgeni_Popov replying, probably he knows better what’s going on here…

Found it!
I have to add the rect to gui before adding other stuff.

    gui.addControl(rect);     
    rect.addControl(msgText);

As far as I know, that shouldn’t be. Though I’m glad it did the fix for you.

There’s definitely a bug there as the original PG is working in 4.2.1 but not in 5.0.40.

Yes i confirm that the same code has always worked in 4.2.1. I noticed this behaviour in 5.40.0 (but i think also in 5.0.0 does the same)

Not sure about that. We would have noticed, may be? Did you check?

No it was a guess :slight_smile:

Hello! This is a side effect of the GUI not being cleaned, but you can just set the invalidate rect optimization to false and it will work: Test GUI with 5.4 | Babylon.js Playground (babylonjs.com)

Thank You @carolhmj,
i’ve many gui elements on my application, is ther any contraindication or side effect using useInvalidateRectOptimization = false ?

invalidateRect is mostly used to not clear the entire area of the GUI if things don’t change between frames, so it improves performance a bit, but the GUI drawing should still be efficient even if turned off. If you notice bad performance when it’s off, please let us know so we can look into it :smiley:

1 Like