PowerQuest 0.19.0
Loading...
Searching...
No Matches
AudioHandle Class Reference

Detailed Description

Audio handle- Use for changing a sound that's currently playing.

  • All the Play(...) functions in the audio system return an AudioHandle. You can store and use this to manipluate the clip that's playing. Especially useful for looping sounds (at least, if you ever want to stop them)
  • It wraps around unity's "AudioSource", but gives access to it so you can still use whatever functionality unity provides with it's AudioSources
  • See Unity's docs on AudioSource for more specific info

Properties

AudioSource source [get]
 Retrieves the unity AudioSource this handle is using.
 
string cueName [get]
 
bool isPlaying [get]
 Is the clip playing right now? (Read Only). Note: will return false when AudioSource.Pause is called.
 
float volume [get, set]
 The base volume of clip (0.0 to 1.0) Before falloff, ducking, etc is applied. To get the final volume, use source.volume.
 
float pitch [get, set]
 The pitch of the audio source. See Unity docs for more info.
 
float panStereo [get, set]
 Pans a playing sound in a stereo way (left or right). See Unity docs for more info.
 
float time [get, set]
 Playback position in seconds. See Unity docs for more info.
 
bool loop [get]
 Is the audio clip looping.
 
float startDelay [set]
 Delay before cue is started- must be set immediately after playing (same as AfterDelay())
 
AudioClip clip [get]
 The audio clip that is playing.
 

Static Public Member Functions

static bool IsPlaying (AudioHandle handle)
 
static bool IsNullOrStopped (AudioHandle handle)
 
static implicit operator AudioSource (AudioHandle handle)
 

Public Member Functions

 AudioHandle (AudioSource source, string fromCue=null)
 
void Pause ()
 Pauses playing the clip.
 
void UnPause ()
 Resumes playing the clip after pausing.
 
void Stop (float overTime=0.0f, float afterDelay=0.0f)
 Stops the clip, optionally fading out over time, and/or after a delay.
 
void AfterDelay (float time)
 Makes the clip start after the passed in time (if called immediately after play) eg. `Audio.Play("GunshotEcho").AfterDelay(1.0f);.
 
AudioHandle FadeIn (float overTime)
 Fades in the sound from zero, call directly after playing the sound to fade it in. eg Audio.Play("MoodyAmbience").FadeIn(1);
 
AudioHandle Fade (float targetVolume, float overTime)
 Fades the volume from it's current volume to another over the specified length of time.
 

Property Documentation

◆ source

AudioSource source
get

Retrieves the unity AudioSource this handle is using.

◆ isPlaying

bool isPlaying
get

Is the clip playing right now? (Read Only). Note: will return false when AudioSource.Pause is called.

◆ volume

float volume
getset

The base volume of clip (0.0 to 1.0) Before falloff, ducking, etc is applied. To get the final volume, use source.volume.

◆ pitch

float pitch
getset

The pitch of the audio source. See Unity docs for more info.

◆ panStereo

float panStereo
getset

Pans a playing sound in a stereo way (left or right). See Unity docs for more info.

◆ time

float time
getset

Playback position in seconds. See Unity docs for more info.

◆ loop

bool loop
get

Is the audio clip looping.

◆ startDelay

float startDelay
set

Delay before cue is started- must be set immediately after playing (same as AfterDelay())

◆ clip

AudioClip clip
get

The audio clip that is playing.

Member Function Documentation

◆ Pause()

void Pause ( )
inline

Pauses playing the clip.

◆ UnPause()

void UnPause ( )
inline

Resumes playing the clip after pausing.

◆ Stop()

void Stop ( float overTime = 0::0f,
float afterDelay = 0::0f )
inline

Stops the clip, optionally fading out over time, and/or after a delay.

◆ AfterDelay()

void AfterDelay ( float time)
inline

Makes the clip start after the passed in time (if called immediately after play) eg. `Audio.Play("GunshotEcho").AfterDelay(1.0f);.

◆ FadeIn()

AudioHandle FadeIn ( float overTime)
inline

Fades in the sound from zero, call directly after playing the sound to fade it in. eg Audio.Play("MoodyAmbience").FadeIn(1);

◆ Fade()

AudioHandle Fade ( float targetVolume,
float overTime )
inline

Fades the volume from it's current volume to another over the specified length of time.