Show / Hide Table of Contents

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

Inheritance
object
Object
Component
Behaviour
MonoBehaviour
AudioPlayer
Implements
IOnPool
Namespace: WeaverCore
Assembly: WeaverCore.dll
Syntax
public sealed class AudioPlayer : MonoBehaviour, IOnPool

Properties

| Edit this page View Source

AudioSource

The audio source that is playing the sound

Declaration
public AudioSource AudioSource { get; }
Property Value
Type Description
AudioSource
| Edit this page View Source

Channel

The audio channel the sound is to be played on

Declaration
public AudioChannel Channel { get; set; }
Property Value
Type Description
AudioChannel
| Edit this page View Source

Clip

The clip that is currently being played

Declaration
public AudioClip Clip { get; set; }
Property Value
Type Description
AudioClip
| Edit this page View Source

Volume

The volume of the audio source

Declaration
public float Volume { get; set; }
Property Value
Type Description
float

Methods

| Edit this page View Source

Delete(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
| Edit this page View Source

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?

| Edit this page View Source

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?

| Edit this page View Source

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?

| Edit this page View Source

StopPlaying()

Stops playing the current Audio Source

Declaration
public void StopPlaying()

Implements

IOnPool

Extension Methods

ReflectionUtilities.ReflectCallMethod(object, string, object[], BindingFlags)
ReflectionUtilities.ReflectGetField(object, string, BindingFlags)
ReflectionUtilities.ReflectGetMethod(object, string, BindingFlags)
ReflectionUtilities.ReflectGetProperty(object, string, BindingFlags)
ReflectionUtilities.ReflectSetField(object, string, object, BindingFlags)
ReflectionUtilities.ReflectSetProperty(object, string, object, BindingFlags)
CoroutineUtilities.RunCoroutineWhile<T>(T, IEnumerator, Func<bool>)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Generated by DocFX
☀
☾