armory3d/zui

When creating UI elements in a loop, elements are 'linked' between loops.

Closed this issue · 2 comments

I feel like this is a bug in how the Id macro works, though I don't understand the code enough to fix it.

Here's a video of the bug in my game: https://video.twimg.com/tweet_video/DAgsMXhXoAA_ugk.mp4
And the code the produces the bug: https://pbs.twimg.com/media/DAgsaCYXsAE0q5r.jpg:large

Thanks!

Sorry, just getting to this now.

Id.handle() is not the most clever thing, have to replace it eventually. It works as a macro, generating handles at compile time to prevent allocations every frame - therefore as a result it has no idea about the for loop..

Untested code follows - this should work to get unique handle in a loop:
for (i in 0...3) Id.handle().nest(i);

Or you could scrap it completely and create new zui.Handle() on your own, but each element has to keep its own handle to remember it's state.

.nest(i) worked great, thanks for your help!

Using it for this WIP tool!