Replies: 2 comments 2 replies
-
Thinking about it, it is "only" a warning I guess, though in a worse case scenario, it might leak memory (I'm guessing those recursive deletion are not running as some elements are deleted some other way it seems, but it is unclear to me whether the entire hierarchy is deleted when that happens). I'll make a note to refactor this later on by just tearing down and re-creating the entire menu. At least deleting an element recursively at the root of the hierarchy has worked well in the past. |
Beta Was this translation helpful? Give feedback.
-
I have found using Events as the best way to update anything UI related. Ideally you would have minimal attributes in each of these structs (preferably Entity's) that you can use in conjunction with Queries to do any spawning/updating/despawning |
Beta Was this translation helpful? Give feedback.
-
I have a sub-section of a ui menu that I want to refresh when a component in my game model changes.
So in a system that reacts to the component change, I want to delete all the children (and their children) of an ui entity and from there re-generate new children.
At first I tried this to delete all the children:
And that didn't work (the action menu was blank). I guessed it was because the "despawn_descendants" command ran asynchronously and actually deleted the new children I created right after calling it.
So then, I tried this to instead target more exactly what I wanted to delete:
And that worked a lot better. But now, I'm getting a bunch of warnings like this:
I'll guess that the existence guard I put on before deletion doesn't help, because the deletion is also asynchronous (so the entity exists at the moment of the check, but no longer exists at the moment of the asynchronous deletion).
I took the hint that I should despawn the entities after removing them as children here, but not sure if that bit of info is obsolete or not: https://bevy-cheatbook.github.io/fundamentals/hierarchy.html#despawning-child-entities
Given that the ui parent-children hiearchy is a tree and don't have any loops, I'm guessing that the "despawn_recursive" is not the problem there.
Any insight would be most welcome.
Beta Was this translation helpful? Give feedback.
All reactions