Search Results for

    Show / Hide Table of Contents

    Class AbstractPlayer<T>

    Generic audio player you can implement to create you own Singleton audio player.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    SingletonBehaviour
    SingletonBehaviour<T>
    AbstractPlayer<T>
    MusicPlayer
    SoundPlayer
    Inherited Members
    SingletonBehaviour<T>.Instance
    SingletonBehaviour<T>.Initialized
    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 Source

    mixerGroup

    Declaration
    [SerializeField]
    protected AudioMixerGroup mixerGroup
    Field Value
    Type Description
    AudioMixerGroup

    The channel used to emit the audio.

    | Edit this page View Source

    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 Source

    Play(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].

    | Edit this page View Source

    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].

    | Edit this page View Source

    Stop()

    Stop whatever is being played.

    Declaration
    public static void Stop()
    | Edit this page View Source

    StopClip()

    Stop whatever is being played.

    Declaration
    protected abstract void StopClip()
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX