@@ -3,17 +3,18 @@ use bevy_asset::{Asset, Handle};
3
3
use bevy_ecs:: prelude:: * ;
4
4
use bevy_math:: Vec3 ;
5
5
use bevy_reflect:: prelude:: * ;
6
+ use bevy_transform:: components:: Transform ;
6
7
7
8
/// The way Bevy manages the sound playback.
8
9
#[ derive( Debug , Clone , Copy , Reflect ) ]
9
10
#[ reflect( Clone ) ]
10
11
pub enum PlaybackMode {
11
12
/// Play the sound once. Do nothing when it ends.
12
13
///
13
- /// Note: It is not possible to reuse an `AudioPlayer` after it has finished playing and
14
- /// the underlying `AudioSink` or `SpatialAudioSink` has been drained.
14
+ /// Note: It is not possible to reuse an [ `AudioPlayer`] after it has finished playing and
15
+ /// the underlying [ `AudioSink`](crate::AudioSink) or [ `SpatialAudioSink`](crate::SpatialAudioSink) has been drained.
15
16
///
16
- /// To replay a sound, the audio components provided by `AudioPlayer` must be removed and
17
+ /// To replay a sound, the audio components provided by [ `AudioPlayer`] must be removed and
17
18
/// added again.
18
19
Once ,
19
20
/// Repeat the sound forever.
@@ -27,7 +28,7 @@ pub enum PlaybackMode {
27
28
/// Initial settings to be used when audio starts playing.
28
29
///
29
30
/// If you would like to control the audio while it is playing, query for the
30
- /// [`AudioSink`][ crate::AudioSink] or [`SpatialAudioSink`][ crate::SpatialAudioSink]
31
+ /// [`AudioSink`]( crate::AudioSink) or [`SpatialAudioSink`]( crate::SpatialAudioSink)
31
32
/// components. Changes to this component will *not* be applied to already-playing audio.
32
33
#[ derive( Component , Clone , Copy , Debug , Reflect ) ]
33
34
#[ reflect( Clone , Default , Component , Debug ) ]
@@ -78,10 +79,10 @@ impl Default for PlaybackSettings {
78
79
impl PlaybackSettings {
79
80
/// Will play the associated audio source once.
80
81
///
81
- /// Note: It is not possible to reuse an `AudioPlayer` after it has finished playing and
82
- /// the underlying `AudioSink` or `SpatialAudioSink` has been drained.
82
+ /// Note: It is not possible to reuse an [ `AudioPlayer`] after it has finished playing and
83
+ /// the underlying [ `AudioSink`](crate::AudioSink) or [ `SpatialAudioSink`](crate::SpatialAudioSink) has been drained.
83
84
///
84
- /// To replay a sound, the audio components provided by `AudioPlayer` must be removed and
85
+ /// To replay a sound, the audio components provided by [ `AudioPlayer`] must be removed and
85
86
/// added again.
86
87
pub const ONCE : PlaybackSettings = PlaybackSettings {
87
88
mode : PlaybackMode :: Once ,
@@ -164,14 +165,15 @@ impl PlaybackSettings {
164
165
165
166
/// Settings for the listener for spatial audio sources.
166
167
///
167
- /// This must be accompanied by `Transform` and `GlobalTransform`.
168
- /// Only one entity with a `SpatialListener` should be present at any given time.
168
+ /// This is accompanied by [ `Transform`] and [ `GlobalTransform`](bevy_transform::prelude::GlobalTransform) .
169
+ /// Only one entity with a [ `SpatialListener`] should be present at any given time.
169
170
#[ derive( Component , Clone , Debug , Reflect ) ]
171
+ #[ require( Transform ) ]
170
172
#[ reflect( Clone , Default , Component , Debug ) ]
171
173
pub struct SpatialListener {
172
- /// Left ear position relative to the `GlobalTransform`.
174
+ /// Left ear position relative to the [ `GlobalTransform`](bevy_transform::prelude::GlobalTransform) .
173
175
pub left_ear_offset : Vec3 ,
174
- /// Right ear position relative to the `GlobalTransform`.
176
+ /// Right ear position relative to the [ `GlobalTransform`](bevy_transform::prelude::GlobalTransform) .
175
177
pub right_ear_offset : Vec3 ,
176
178
}
177
179
@@ -182,7 +184,7 @@ impl Default for SpatialListener {
182
184
}
183
185
184
186
impl SpatialListener {
185
- /// Creates a new `SpatialListener` component.
187
+ /// Creates a new [ `SpatialListener`] component.
186
188
///
187
189
/// `gap` is the distance between the left and right "ears" of the listener. Ears are
188
190
/// positioned on the x axis.
@@ -203,12 +205,12 @@ impl SpatialListener {
203
205
pub struct SpatialScale ( pub Vec3 ) ;
204
206
205
207
impl SpatialScale {
206
- /// Create a new `SpatialScale` with the same value for all 3 dimensions.
208
+ /// Create a new [ `SpatialScale`] with the same value for all 3 dimensions.
207
209
pub const fn new ( scale : f32 ) -> Self {
208
210
Self ( Vec3 :: splat ( scale) )
209
211
}
210
212
211
- /// Create a new `SpatialScale` with the same value for `x` and `y`, and `0.0`
213
+ /// Create a new [ `SpatialScale`] with the same value for `x` and `y`, and `0.0`
212
214
/// for `z`.
213
215
pub const fn new_2d ( scale : f32 ) -> Self {
214
216
Self ( Vec3 :: new ( scale, scale, 0.0 ) )
@@ -238,11 +240,11 @@ pub struct DefaultSpatialScale(pub SpatialScale);
238
240
/// If the handle refers to an unavailable asset (such as if it has not finished loading yet),
239
241
/// the audio will not begin playing immediately. The audio will play when the asset is ready.
240
242
///
241
- /// When Bevy begins the audio playback, an [`AudioSink`][ crate::AudioSink] component will be
243
+ /// When Bevy begins the audio playback, an [`AudioSink`]( crate::AudioSink) component will be
242
244
/// added to the entity. You can use that component to control the audio settings during playback.
243
245
///
244
246
/// Playback can be configured using the [`PlaybackSettings`] component. Note that changes to the
245
- /// `PlaybackSettings` component will *not* affect already-playing audio.
247
+ /// [ `PlaybackSettings`] component will *not* affect already-playing audio.
246
248
#[ derive( Component , Reflect ) ]
247
249
#[ reflect( Component , Clone ) ]
248
250
#[ require( PlaybackSettings ) ]
0 commit comments