-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bevy_quill_obsidian will crash if you use StateScoped to remove UI when state changes #3
Comments
So the current solution for despawning UI roots is less than ideal, as it requires calling The eventual goal is to use relations to track ownership, along with component hooks, so that whenever you delete a view root entity all of the things that it owns also despawn automatically. But this is of course waiting on relations...although it may be possible to do something with just component hooks alone. It's a bit complex because hooks only get a deferred world, which means that any actual despawning has to be handled in the command queue. Researching this is one of the things on my TODO list. |
how exactly do I call raze on a view root? I have been trying to work it out but cant work out how to get access to a pubic call to raze, the only one I found doesn't relate back to my root node in any way, I am probably missing something obvious. p.s. would it be possible to add an example of how to cleanup or remove UI |
OK, I added some public APIs for despawning a view root, and an example that illustrates how it works: b169936 The code isn't pretty, but as I mentioned earlier, hopefully this will get better. |
I've worked on this more. You should now be able to despawn view roots normally with despawn(). In order to make this work, I had to change the |
Ah, I thought I was going crazy. So this lib is the reason my StateScoped menus are crashing when switching to a new SubState. This lib is great so far! I just really wish that StateScoped UI would work as well :/ |
A little helper function I'm using for now. But long term: I would love to be able to use StateScoped again! pub fn despawn_ui_with_marker<C: Component>(mut commands: Commands, query: Query<Entity, With<C>>) {
commands.entity(query.single()).despawn();
} |
I was trying to use StateScoped to despawn my UI when the state change but this results in a crash because bevy_quill_obsidian tries to access the entity for a hover check after it has respawned, what is the correct why to remove UI? I don't think the application should crash if I despawn part of the UI
The text was updated successfully, but these errors were encountered: