Click or drag to resize

AudioFader Class

Attach it to a GameObject with an AudioSource and this component will allow you to play, pause, stop, and change volume or clip with the volume fading in/out.
Inheritance Hierarchy
SystemObject
  Object
    Component
      Behaviour
        MonoBehaviour
          Kit.BehavioursAudioFader

Namespace:  Kit.Behaviours
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0
Syntax
C#
public class AudioFader : MonoBehaviour
Request Example View Source

The AudioFader type exposes the following members.

Properties
  NameDescription
Public propertyClip
Returns the audio currently playing or allows to change it while fading.
Public propertyIsBusy
Returns whether the audio is fading (in or out).
Public propertyIsPlaying
Returns whether an audio is currently playing or allows to play or pause it.
Public propertyVolume
Returns the current volume or allows to set it while fading.
Top
Methods
  NameDescription
Public methodPause
Pause and fade-out the audio.
Public methodPlay
Play and fade-in the audio.
Public methodPlay(AudioClip)
Play an audio.
Public methodStop
Stop and fade out the audio.
Top
Fields
  NameDescription
Public fieldAudio

AudioSource to fade.

Will use the one on the same GameObject if not specified.

Public fieldFadeOnSceneChange
Should the audio automatically fade in/out when changing the scene with SceneDirector?
Public fieldFadeWithScreen
Should the audio automatically fade in/out with the scene when you use SceneDirector?
Public fieldSpeed
How fast to fade the audio.
Top
Extension Methods
  NameDescription
Public Extension MethodDestroy
Destroy the object.
(Defined by UnityObjectExtensions.)
Public Extension MethodDisable
Set the enabled property to .
(Defined by BehaviourExtensions.)
Public Extension MethodEnable
Set the enabled property to .
(Defined by BehaviourExtensions.)
Public Extension MethodGetBounds

Returns the bounds of the Component.

(Defined by ComponentExtensions.)
Public Extension MethodIsPrefab
Returns whether the Component is a part of a prefab.
(Defined by ComponentExtensions.)
Top
Remarks
Just attaching it to an AudioSource with playOnAwake will fade the audio in on Awake.
See Also