Fix issue with adding icons to despawned entities.
This commit is contained in:
parent
015e98d419
commit
fb34f6ef12
|
@ -31,11 +31,12 @@ impl Default for SoundIcon {
|
||||||
|
|
||||||
fn added(mut commands: Commands, icons: Query<(Entity, &SoundIcon), Added<SoundIcon>>) {
|
fn added(mut commands: Commands, icons: Query<(Entity, &SoundIcon), Added<SoundIcon>>) {
|
||||||
for (entity, icon) in &icons {
|
for (entity, icon) in &icons {
|
||||||
|
if let Some(mut commands) = commands.get_entity(entity) {
|
||||||
let buffer = icon.audio.clone();
|
let buffer = icon.audio.clone();
|
||||||
let gain = icon.gain;
|
let gain = icon.gain;
|
||||||
let pitch = icon.pitch;
|
let pitch = icon.pitch;
|
||||||
let looping = icon.interval.is_none();
|
let looping = icon.interval.is_none();
|
||||||
commands.entity(entity).insert(Sound {
|
commands.insert(Sound {
|
||||||
audio: buffer,
|
audio: buffer,
|
||||||
gain,
|
gain,
|
||||||
pitch,
|
pitch,
|
||||||
|
@ -45,6 +46,7 @@ fn added(mut commands: Commands, icons: Query<(Entity, &SoundIcon), Added<SoundI
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn update<S>(
|
fn update<S>(
|
||||||
config: Res<SoundIconPlugin<S>>,
|
config: Res<SoundIconPlugin<S>>,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user