Class AudioPlayer
Used for playing audio sounds.
This class allows you to play sounds on specific channels (like the music channel, or the SFX channel), for greater sound control
Implements
Namespace: WeaverCore
Assembly: WeaverCore.dll
Syntax
public sealed class AudioPlayer : MonoBehaviour, IOnPool
Properties
| Edit this page View SourceAudioSource
The audio source that is playing the sound
Declaration
public AudioSource AudioSource { get; }
Property Value
| Type | Description |
|---|---|
| AudioSource |
Channel
The audio channel the sound is to be played on
Declaration
public AudioChannel Channel { get; set; }
Property Value
| Type | Description |
|---|---|
| AudioChannel |
Clip
The clip that is currently being played
Declaration
public AudioClip Clip { get; set; }
Property Value
| Type | Description |
|---|---|
| AudioClip |
Volume
The volume of the audio source
Declaration
public float Volume { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
| Edit this page View SourceDelete(float)
Destroys the audio player. If this audio player was created from a pool, this function will return it to the pool
Declaration
public void Delete(float timer = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| float | timer |
Play(bool)
Plays the Audio Source
Declaration
public void Play(bool deleteWhenDone = false)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | deleteWhenDone | Should this audio player be deleted when done? |
Play(AudioClip, float, AudioChannel, bool)
Plays an audio clip on this audio player
Declaration
public void Play(AudioClip clip, float volume = 1, AudioChannel channel = AudioChannel.Sound, bool deleteWhenDone = false)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioClip | clip | The clip to be played |
| float | volume | The volume of the clip |
| AudioChannel | channel | What audio channel should the sound be played under? |
| bool | deleteWhenDone | Should this audio player be deleted when done? |
PlayDelayed(float, bool)
Plays the Audio Source after a set delay
Declaration
public void PlayDelayed(float delay, bool deleteWhenDone = true)
Parameters
| Type | Name | Description |
|---|---|---|
| float | delay | The delay before the sound is played |
| bool | deleteWhenDone | Should this audio player be deleted when done? |
StopPlaying()
Stops playing the current Audio Source
Declaration
public void StopPlaying()