From 42098192c228bd1329ff9ff1a4848c030ec171ec Mon Sep 17 00:00:00 2001 From: Ray Redondo Date: Thu, 3 Aug 2023 07:46:44 -0500 Subject: [PATCH] update documentation on AudioSink (#9332) # Objective When an `AudioSink` is removed from an entity, the audio player will automatically start any `AudioSource` still attached, which normally is the one used to start playback in the first place. ## Solution Long story short, the default behavior is restarting the audio, and this commit documents that. --- ## Changelog Fixed documentation on `AudioSink` to clarify removal behavior. --- crates/bevy_audio/src/sinks.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/bevy_audio/src/sinks.rs b/crates/bevy_audio/src/sinks.rs index 2f5cf4c29c..d53e32db62 100644 --- a/crates/bevy_audio/src/sinks.rs +++ b/crates/bevy_audio/src/sinks.rs @@ -71,6 +71,10 @@ pub trait AudioSinkPlayback { /// Use [`AudioBundle`][crate::AudioBundle] to trigger that to happen. /// /// You can use this component to modify the playback settings while the audio is playing. +/// +/// If this component is removed from an entity, and an [`AudioSource`][crate::AudioSource] is +/// attached to that entity, that [`AudioSource`][crate::AudioSource] will start playing. If +/// that source is unchanged, that translates to the audio restarting. #[derive(Component)] pub struct AudioSink { // This field is an Option in order to allow us to have a safe drop that will detach the sink. @@ -128,6 +132,10 @@ impl AudioSinkPlayback for AudioSink { /// Use [`SpatialAudioBundle`][crate::SpatialAudioBundle] to trigger that to happen. /// /// You can use this component to modify the playback settings while the audio is playing. +/// +/// If this component is removed from an entity, and a [`AudioSource`][crate::AudioSource] is +/// attached to that entity, that [`AudioSource`][crate::AudioSource] will start playing. If +/// that source is unchanged, that translates to the audio restarting. #[derive(Component)] pub struct SpatialAudioSink { // This field is an Option in order to allow us to have a safe drop that will detach the sink.