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