From d2cea7f1abd23120a9a2240afc40fd9e3c2f1aa8 Mon Sep 17 00:00:00 2001 From: Franklin Date: Sun, 24 Mar 2024 16:31:25 +0100 Subject: [PATCH] Even more bugs. Sorry :( --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/update.rs | 4 +++- src/utils.rs | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dabd80e..11630b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -608,7 +608,7 @@ dependencies = [ [[package]] name = "bevy_icon_creator" -version = "0.1.6" +version = "0.1.7" dependencies = [ "bevy", ] diff --git a/Cargo.toml b/Cargo.toml index aefb026..1ef59b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_icon_creator" -version = "0.1.6" +version = "0.1.7" edition = "2021" authors = ["Franklin E. Blanco"] description = "A plugin to automatically create Icons from entities/models in bevy" diff --git a/src/update.rs b/src/update.rs index 73b6ecb..bd4ebbc 100644 --- a/src/update.rs +++ b/src/update.rs @@ -16,7 +16,7 @@ pub fn update_icon_creator_scenes( mut images: ResMut>, mut created_icons: ResMut, ) { - for (scene_root_entity, scene_marker, mut scene_root_visibility, mut scene_root_marker) in scene_query.iter_mut() { + 'a: for (scene_root_entity, scene_marker, mut scene_root_visibility, mut scene_root_marker) in scene_query.iter_mut() { for (mut scene_camera, in_scene) in scene_camera_query.iter_mut() { if scene_marker.0 != in_scene.0 { continue; } for (scene_parent_entity, in_scene) in scene_entity_parent_query.iter() { @@ -37,6 +37,7 @@ pub fn update_icon_creator_scenes( scene_camera.target = RenderTarget::Image(camera_target_image_handle); } else if scene_root_marker.0 >= MIN_FRAMES_TO_RENDER + entity_getting_icon_marker.extra_frames.unwrap_or(0) { commands.entity(scene_root_entity).remove::(); + scene_root_marker.0 = 0; if let Some(mut entity_commands) = commands.get_entity(scene_parent_entity) { // Unoccupy entity_commands.remove::(); scene_camera.is_active = false; @@ -44,6 +45,7 @@ pub fn update_icon_creator_scenes( scene_camera.target = RenderTarget::default(); entity_commands.despawn_descendants(); } + continue 'a; } } scene_root_marker.0 += 1; diff --git a/src/utils.rs b/src/utils.rs index 1a9fe20..6202273 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -9,7 +9,7 @@ pub fn mark_all_children_with_component( ) { if mark_parent { if let Some(mut entity_commands) = commands.get_entity(entity) { - entity_commands.insert(bundle.clone()); + entity_commands.try_insert(bundle.clone()); } } mark_all_children_with_component_recursive(commands, entity, children_query, bundle, true); @@ -29,7 +29,7 @@ fn mark_all_children_with_component_recursive( } if !first_time { if let Some(mut entity_commands) = commands.get_entity(entity) { - entity_commands.insert(bundle); + entity_commands.try_insert(bundle); } } } \ No newline at end of file