I currently have a list of entities in a layout group that I want to reorder with script. I thought I’d be able to remove them with removeChild() and re-add them in the new order, but removeChild doesn’t seem to actually stop them from being rendered. The only way I’ve managed to get what I want is to clone all the children, destroy() the originals and then add the clones. This seems like too much work for something so simple. Is there a better way to do this?
Is this for the 2D UI canvas? Rather than destroying them, you could disable the entity instead.
I made a small project to give example:
Thanks LeXXik! That’s just what I needed
Hey @LeXXik, can you confirm if this works during runtime? I couldnt get it to work, at least.
I have a layoutgroup with 30 children that will be reordered about once a second. Each of these children has a lot of children themselves, so I’d like to avoid cloning if possible.
Edit: Figured it out. A call to layoutgroup.reflow() did the trick. Found it in the typescript definition file, but should probably include it in the docs? LayoutGroupComponent | PlayCanvas API Reference
I’ve added a feature request for you: