Add option check.

This commit is contained in:
Nolan Darilek 2022-05-31 10:17:16 -05:00
parent 1022037efe
commit a26cf344d6

View File

@ -101,10 +101,13 @@ fn update<S>(
for visible in viewers.iter() {
for (icon_entity, mut icon, visibility, parent, mut sound) in icons.iter_mut() {
let entity = if visibility.is_some() {
icon_entity
Some(icon_entity)
} else if parent.is_some() {
Some(**parent.unwrap())
} else {
**parent.unwrap()
None
};
if let Some(entity) = entity {
if visible.contains(&entity) {
let looping = sound.looping;
if looping {
@ -126,6 +129,7 @@ fn update<S>(
sound.reference_distance = icon.reference_distance;
sound.max_distance = icon.max_distance;
sound.rolloff_factor = icon.rolloff_factor;
}
} else {
sound.state = SoundState::Stopped;
}