Class TweenAudioSourceExtensions
Provides extension methods for animating UnityEngine.AudioSource properties using the Scylla tween system.
Covers volume (with dedicated fade-in, fade-out, and fade-out-and-stop helpers), pitch, spatial blend, and stereo pan. All methods clamp their target values to the valid ranges accepted by UnityEngine.AudioSource.
All methods return a pre-configured tween instance sourced from TweenPool. The
tween is not started automatically - call Play() or
PlayManaged(ITween) on the returned instance to begin playback. The start
value is captured lazily from the UnityEngine.AudioSource at the moment playback begins,
unless you override it with a SetFrom call before playing.
Inherited Members
Namespace: Scylla.Core.Util.Tween
Assembly: ScyllaCore.dll
Syntax
public static class TweenAudioSourceExtensions
Methods
TweenFadeIn(AudioSource, float)
Creates a tween that fades an audio source in by animating its
UnityEngine.AudioSource.volume from 0 to 1 over the specified duration,
regardless of the audio source's current volume.
Unlike TweenVolume(AudioSource, float, float), which starts from the current volume, this method forces
the start value to 0 via SetFrom(float) so the audio always
begins silent. The audio source is not started or stopped by this tween - ensure it is
already playing before calling this method if audio output is desired.
Declaration
public static TweenFloat TweenFadeIn(this AudioSource audioSource, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioSource | audioSource | The audio source to fade in. Must not be |
| float | duration | The length of the fade-in animation in seconds. |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenFadeOut(AudioSource, float)
Creates a tween that fades an audio source out by animating its
UnityEngine.AudioSource.volume from its current value to 0 over the specified
duration.
The audio source is not stopped when the fade completes. Use TweenFadeOutAndStop(AudioSource, float) if you want the audio source to stop automatically after the fade.
Declaration
public static TweenFloat TweenFadeOut(this AudioSource audioSource, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioSource | audioSource | The audio source to fade out. Must not be |
| float | duration | The length of the fade-out animation in seconds. |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenFadeOutAndStop(AudioSource, float)
Creates a tween that fades an audio source out by animating its
UnityEngine.AudioSource.volume from its current value to 0 over the specified
duration, then calls UnityEngine.AudioSource.Stop() when the fade completes.
This is a convenience wrapper over TweenFadeOut(AudioSource, float) that appends an
OnComplete(Action) callback to stop the audio source. The volume is not reset
to its pre-fade value after stopping, so the audio source will remain at volume 0
until you change it explicitly.
Declaration
public static TweenFloat TweenFadeOutAndStop(this AudioSource audioSource, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioSource | audioSource | The audio source to fade out and stop. Must not be |
| float | duration | The length of the fade-out animation in seconds. |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance configured with an |
See Also
TweenPanStereo(AudioSource, float, float)
Creates a tween that animates the UnityEngine.AudioSource.panStereo of an audio source from
its current value to endValue over the specified duration.
Stereo pan controls the left/right balance of the audio output. A value of -1 pans
fully to the left channel, 0 is centered, and 1 pans fully to the right
channel. endValue is clamped to [-1, 1] via Clamp(float, float, float).
Declaration
public static TweenFloat TweenPanStereo(this AudioSource audioSource, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioSource | audioSource | The audio source whose stereo pan will be animated. Must not be |
| float | endValue | The target stereo pan value. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
TweenPitch(AudioSource, float, float)
Creates a tween that animates the UnityEngine.AudioSource.pitch of an audio source from its
current value to endValue over the specified duration.
endValue is clamped to [-3, 3] via Clamp(float, float, float) before the
tween is initialized, matching Unity's valid range for UnityEngine.AudioSource.pitch. A
pitch of 1 is normal speed; values below 1 slow the audio down and values
above 1 speed it up. Negative values play the audio in reverse.
Declaration
public static TweenFloat TweenPitch(this AudioSource audioSource, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioSource | audioSource | The audio source whose pitch will be animated. Must not be |
| float | endValue | The target pitch value. Values outside [-3, 3] are clamped to that range automatically. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
TweenSpatialBlend(AudioSource, float, float)
Creates a tween that animates the UnityEngine.AudioSource.spatialBlend of an audio source
from its current value to endValue over the specified duration.
Spatial blend controls the mix between 2D and 3D spatialization. A value of 0 is
fully 2D (ignores 3D position), while 1 is fully 3D (affected by distance and
position relative to the listener). endValue is clamped to [0, 1].
Declaration
public static TweenFloat TweenSpatialBlend(this AudioSource audioSource, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioSource | audioSource | The audio source whose spatial blend will be animated. Must not be |
| float | endValue | The target spatial blend value. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
TweenVolume(AudioSource, float, float)
Creates a tween that animates the UnityEngine.AudioSource.volume of an audio source from its
current value to endValue over the specified duration.
endValue is clamped to [0, 1] via Clamp01(float) before
the tween is initialized, matching the valid range for UnityEngine.AudioSource.volume.
Declaration
public static TweenFloat TweenVolume(this AudioSource audioSource, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioSource | audioSource | The audio source whose volume will be animated. Must not be |
| float | endValue | The target volume level. Values outside [0, 1] are clamped to that range automatically. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |