Adventure Creator  1.66.8
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2018
AC.Sound Class Reference
Inheritance diagram for AC.Sound:
AC.Soundtrack AC.Ambience AC.Music

Public Member Functions

void AfterLoad ()
 
void AfterLoading ()
 
virtual void _Update ()
 
void Interact ()
 
void FadeIn (float _fadeTime, bool loop, int _timeSamples=0)
 Fades in the AudioSource's current AudioClip, after which it continues to play. More...
 
void FadeOut (float _fadeTime)
 Fades out the AudioSource's current AudioClip, after which it stops. More...
 
bool IsFadingOut ()
 Checks if the AudioSource's AudioClip is being faded out. More...
 
void Play ()
 Plays the AudioSource's current AudioClip, without starting over if it was paused or changing its "loop" variable.
 
void Play (bool loop)
 Plays the AudioSource's current AudioClip. More...
 
void Play (AudioClip clip, bool loop, int _timeSamples=0)
 Plays an AudioClip. More...
 
void PlayAtPoint (bool loop, int samplePoint)
 Plays the AudioSource's current AudioClip from a set point. More...
 
void SetMaxVolume ()
 
void SetVolume (float volume)
 Sets the volume, but takes relativeVolume into account as well. More...
 
void ChangeRelativeVolume (float newRelativeVolume, float changeTime=0f)
 Changes the relativeVolume value. More...
 
void Stop ()
 
bool IsFading ()
 Checks if the sound is fading in or out. More...
 
bool IsPlaying ()
 Checks if sound is playing. More...
 
bool IsPlaying (AudioClip clip)
 Checks if a particular AudioClip is playing. More...
 
void TryDestroy ()
 
void EndOld (SoundType _soundType, Sound ignoreSound)
 Fades out all sounds of a particular type being played. More...
 
SoundData GetSaveData (SoundData soundData)
 Updates a SoundData class with its own variables that need saving. More...
 
void LoadData (SoundData soundData)
 Updates its own variables from a SoundData class. More...
 

Public Attributes

SoundType soundType
 
bool playWhilePaused = false
 
float relativeVolume = 1f
 
bool surviveSceneChange = false
 

Protected Member Functions

void Initialise ()
 

Protected Attributes

AudioSource audioSource
 

Detailed Description

This component controls the volume of the AudioSource component it is attached beside, according to the volume levels set within OptionsData by the player. It also allows for AudioSources to be controlled using Actions.

Member Function Documentation

◆ _Update()

virtual void AC.Sound._Update ( )
virtual

Updates the AudioSource's volume. This is called every frame by StateHandler.

Reimplemented in AC.Soundtrack.

◆ AfterLoad()

void AC.Sound.AfterLoad ( )

Called after a scene change.

◆ AfterLoading()

void AC.Sound.AfterLoading ( )

Initialises the AudioSource's volume, when the scene begins.

◆ ChangeRelativeVolume()

void AC.Sound.ChangeRelativeVolume ( float  newRelativeVolume,
float  changeTime = 0f 
)

Changes the relativeVolume value.

Parameters
newRelativeVolumeThe new value for relativeVolume
changeTimeThe time, in seconds, to make the change in

◆ EndOld()

void AC.Sound.EndOld ( SoundType  _soundType,
Sound  ignoreSound 
)

Fades out all sounds of a particular type being played.

Parameters
soundTypeIf the soundType matches this, the sound will end
ignoreSoundThe Sound object to not affect

◆ FadeIn()

void AC.Sound.FadeIn ( float  _fadeTime,
bool  loop,
int  _timeSamples = 0 
)

Fades in the AudioSource's current AudioClip, after which it continues to play.

Parameters
_fadeTimeThe fade duration, in seconds
loopIf True, then the AudioClip will loop
_timeSamplesThe timeSamples to play from

◆ FadeOut()

void AC.Sound.FadeOut ( float  _fadeTime)

Fades out the AudioSource's current AudioClip, after which it stops.

Parameters
_fadeTimeThe fade duration, in seconds

◆ GetSaveData()

SoundData AC.Sound.GetSaveData ( SoundData  soundData)

Updates a SoundData class with its own variables that need saving.

Parameters
soundDataThe original SoundData class
Returns
The updated SoundData class

◆ Interact()

void AC.Sound.Interact ( )

Plays the AudioSource's current AudioClip.

◆ IsFading()

bool AC.Sound.IsFading ( )

Checks if the sound is fading in or out.

Returns
True if the sound is fading in or out

◆ IsFadingOut()

bool AC.Sound.IsFadingOut ( )

Checks if the AudioSource's AudioClip is being faded out.

Returns
True if the AudioSource's AudioClip is being faded out

◆ IsPlaying() [1/2]

bool AC.Sound.IsPlaying ( )

Checks if sound is playing.

Returns
True if sound is playing

◆ IsPlaying() [2/2]

bool AC.Sound.IsPlaying ( AudioClip  clip)

Checks if a particular AudioClip is playing.

Parameters
clipThe AudioClip to check for
Returns
True if the AudioClip is playing

◆ LoadData()

void AC.Sound.LoadData ( SoundData  soundData)

Updates its own variables from a SoundData class.

Parameters
soundDataThe SoundData class to load from

◆ Play() [1/2]

void AC.Sound.Play ( bool  loop)

Plays the AudioSource's current AudioClip.

Parameters
loopIf true, the AudioClip will be looped

◆ Play() [2/2]

void AC.Sound.Play ( AudioClip  clip,
bool  loop,
int  _timeSamples = 0 
)

Plays an AudioClip.

Parameters
clipThe AudioClip to play
loopIf true, the AudioClip will be looped
_timeSamplesThe timeSamples to play from

◆ PlayAtPoint()

void AC.Sound.PlayAtPoint ( bool  loop,
int  samplePoint 
)

Plays the AudioSource's current AudioClip from a set point.

Parameters
loopIf true, the AudioClip will be looped
samplePointThe playback position in PCM samples

◆ SetMaxVolume()

void AC.Sound.SetMaxVolume ( )

Calculates the maximum volume that the AudioSource can have. This should be called whenever the volume in OptionsData is changed.

◆ SetVolume()

void AC.Sound.SetVolume ( float  volume)

Sets the volume, but takes relativeVolume into account as well.

Parameters
volumeThe volume to set

◆ Stop()

void AC.Sound.Stop ( )

Abrubtply stops the currently-playing sound.

◆ TryDestroy()

void AC.Sound.TryDestroy ( )

Destroys itself, if it should do.

Member Data Documentation

◆ playWhilePaused

bool AC.Sound.playWhilePaused = false

If True, then the sound can play when the game is paused

◆ relativeVolume

float AC.Sound.relativeVolume = 1f

The volume of the sound, relative to its categoriy's "global" volume set within OptionsData

◆ soundType

SoundType AC.Sound.soundType

The type of sound, so far as volume levels go (SFX, Music, Other)

◆ surviveSceneChange

bool AC.Sound.surviveSceneChange = false

If True, then the GameObject this is attached to will not be destroyed when changing scene