Skip to content

Commit

Permalink
Despawn children of the example dialogue view instead of orphaning them
Browse files Browse the repository at this point in the history
  • Loading branch information
wiggleforlife committed Dec 14, 2024
1 parent 70609d2 commit d774daa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/example_dialogue_view/src/typewriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ impl Typewriter {

fn write_text(
mut commands: Commands,
mut text: Query<Entity, (With<DialogueNode>, With<Text>)>, //TODO are both filters needed
mut text: Query<Entity, With<DialogueNode>>,
mut typewriter: ResMut<Typewriter>,
option_selection: Option<Res<OptionSelection>>,
mut speaker_change_events: EventWriter<SpeakerChangeEvent>,
mut root_visibility: Query<&mut Visibility, With<UiRootNode>>,
) {
let mut text_entity = commands.entity(text.single_mut());
if typewriter.last_before_options && option_selection.is_none() {
text_entity.clear_children();
text_entity.despawn_descendants();
return;
}
if typewriter.is_finished() {
Expand All @@ -132,7 +132,7 @@ fn write_text(
let current_text = &typewriter.current_text;
let rest = typewriter.graphemes_left.join("");
let spans = create_dialog_text(current_text, rest);
text_entity.clear_children().with_children(|parent| {
text_entity.despawn_descendants().with_children(|parent| {
parent.spawn(spans[0].clone());
parent.spawn(spans[1].clone());
});
Expand Down

0 comments on commit d774daa

Please sign in to comment.