Reset source when panner strategy changes or is removed.
This commit is contained in:
parent
28718d2e85
commit
5615a28ece
25
src/lib.rs
25
src/lib.rs
|
@ -199,6 +199,27 @@ fn swap_buffers(
|
|||
}
|
||||
}
|
||||
|
||||
fn change_panner_strategy(
|
||||
changed: Query<Entity, Changed<PannerStrategy>>,
|
||||
removed: RemovedComponents<PannerStrategy>,
|
||||
mut sounds: Query<&mut Sound>,
|
||||
) {
|
||||
let mut check = vec![];
|
||||
for entity in changed.iter() {
|
||||
check.push(entity);
|
||||
}
|
||||
for entity in removed.iter() {
|
||||
check.push(entity);
|
||||
}
|
||||
for entity in check.iter() {
|
||||
if let Ok(mut sound) = sounds.get_mut(*entity) {
|
||||
if sound.source.is_some() {
|
||||
sound.source = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_sound_properties(
|
||||
context: Res<syz::Context>,
|
||||
buffers: Res<Assets<Buffer>>,
|
||||
|
@ -571,6 +592,10 @@ impl Plugin for SynthizerPlugin {
|
|||
CoreStage::PostUpdate,
|
||||
swap_buffers.before(update_sound_properties),
|
||||
)
|
||||
.add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
change_panner_strategy.before(update_sound_properties),
|
||||
)
|
||||
.add_system_to_stage(
|
||||
CoreStage::PostUpdate,
|
||||
update_listener
|
||||
|
|
Loading…
Reference in New Issue
Block a user