Class AbstractPlayer<T>
Generic audio player you can implement to create you own Singleton audio player.
Inheritance
Object
Component
Behaviour
MonoBehaviour
AbstractPlayer<T>
Namespace: GGL.Audio.Player
Assembly: GGL.dll
Syntax
[HelpURL("https://ggl.yoannhaffner.com/articles/audio.html#optimisation")]
public abstract class AbstractPlayer<T> : SingletonBehaviour<T> where T : AbstractPlayer<T>
Type Parameters
Name | Description |
---|---|
T | Your script so that it can be set as Singleton. |
Remarks
To learn how to properly inherit this class, check the HelpURL attribute.
Examples
MusicPlayer and SoundPlayer are good examples of what you can do.
Fields
| Edit this page View SourcemixerGroup
Declaration
[SerializeField]
protected AudioMixerGroup mixerGroup
Field Value
Type | Description |
---|---|
AudioMixerGroup | The channel used to emit the audio. |
player
Declaration
[SerializeField]
protected AudioSource player
Field Value
Type | Description |
---|---|
AudioSource | The associated player: it should be script's object or its children to benefit the cross-scene advantage. |
Methods
| Edit this page View SourcePlay(AudioClip, float)
Play an audio file.
Declaration
public static void Play(AudioClip clip, float volume = 1)
Parameters
Type | Name | Description |
---|---|---|
AudioClip | clip | Audio file to play. |
float | volume | Volume in range [0;1]. |
PlayClip(AudioClip, float)
Play an audio file.
Declaration
protected abstract void PlayClip(AudioClip clip, float volume = 1)
Parameters
Type | Name | Description |
---|---|---|
AudioClip | clip | Audio file to play. |
float | volume | Volume in range [0;1]. |
Stop()
Stop whatever is being played.
Declaration
public static void Stop()
StopClip()
Stop whatever is being played.
Declaration
protected abstract void StopClip()