Skip to content

Commit d774daa

Browse files
committed
Despawn children of the example dialogue view instead of orphaning them
1 parent 70609d2 commit d774daa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crates/example_dialogue_view/src/typewriter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ impl Typewriter {
101101

102102
fn write_text(
103103
mut commands: Commands,
104-
mut text: Query<Entity, (With<DialogueNode>, With<Text>)>, //TODO are both filters needed
104+
mut text: Query<Entity, With<DialogueNode>>,
105105
mut typewriter: ResMut<Typewriter>,
106106
option_selection: Option<Res<OptionSelection>>,
107107
mut speaker_change_events: EventWriter<SpeakerChangeEvent>,
108108
mut root_visibility: Query<&mut Visibility, With<UiRootNode>>,
109109
) {
110110
let mut text_entity = commands.entity(text.single_mut());
111111
if typewriter.last_before_options && option_selection.is_none() {
112-
text_entity.clear_children();
112+
text_entity.despawn_descendants();
113113
return;
114114
}
115115
if typewriter.is_finished() {
@@ -132,7 +132,7 @@ fn write_text(
132132
let current_text = &typewriter.current_text;
133133
let rest = typewriter.graphemes_left.join("");
134134
let spans = create_dialog_text(current_text, rest);
135-
text_entity.clear_children().with_children(|parent| {
135+
text_entity.despawn_descendants().with_children(|parent| {
136136
parent.spawn(spans[0].clone());
137137
parent.spawn(spans[1].clone());
138138
});

0 commit comments

Comments
 (0)