Replies: 1 comment
-
I changed the fn load(
mut commands: Commands,
server: Res<AssetServer>,
roots: Query<Entity, (Without<Parent>, With<Counter>)>,
) {
let scene = server.load("scene.scn.ron");
server.reload("scene.scn.ron");
if !server.is_loaded(scene.id()) {
for entity in &roots {
commands.entity(entity).despawn_recursive();
}
commands.spawn(DynamicSceneRoot(scene));
}
} It seems to sometimes work now, but it's super weird. If the first thing I do when the program starts is |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to do some super basic saving/loading/reloading of scenes.
TLDR: I get duplicate entities when reloading a scene after saving it via a system.
Consider the following code:
I want to recursively despawn the entities in the scene before spawning it, the root will be
Counter
if the scene has not been loaded orDynamicSceneRoot
if it is already loaded.Then I want to reload or load the scene depending on if it's already loaded and then spawn the loaded scene. This shouldn't result in duplicate entities since we despawned everything prior. right?
This kind off works, when the
load
system runs, the scene get reloaded from the file. However if I save the scene using thesave
system, and then try to load it again, I get two instances ofCounter
entities. This is despite despawning all the entities before loading. If I then run theload
system once more, the duplicate entity disappears and everything is fine.Interestingly, if I edit the scene asset in the code editor rather than saving it via the
save
system, it seems to work as expected when I reload it.This is very confusing to me and seems quite inconsistent. Here's the rest of the code if interested: https://gist.github.com/atornity/bd735c4b755a63a33c7632ac8ab084d1
Beta Was this translation helpful? Give feedback.
All reactions