Class IntroloopPlayer<T>
An abstract
class that grants you a new set of convenient singleton instance just like the
Instance, but now under your own self-defined class name.
(e.g. You can now call MyIntroloopPlayer.Instance
and so on.)
Inheritance
System.Object
UnityEngine.Object
UnityEngine.Component
UnityEngine.Behaviour
UnityEngine.MonoBehaviour
IntroloopPlayer<T>
Inherited Members
Namespace: E7.Introloop
Assembly: E7.Introloop.dll
Syntax
public abstract class IntroloopPlayer<T> : IntroloopPlayer where T : IntroloopPlayer
Type Parameters
Name | Description |
---|---|
T |
Remarks
This class utilize C# trick where each unique combination of generic class gives you a
unique instance of static
variables. Putting your self-defined class itself inside T
basically give you a personal set of static
.
Define your class like this :
public class FieldBGMPlayer : IntroloopPlayer<FieldBGMPlayer>
(Put your class itself into the generic variable.)
Properties
Instance
Get a convenient singleton instance of abstract
class.
It has DontDestroyOnLoad
applied.
Before calling this for the first time, call SetSingletonInstanceTemplateSource(AudioSource) first to setup its TemplateSource from script. (It does not exist until runtime, you cannot setup the template ahead of time unlike non-singleton instances.)
Declaration
public static T Instance { get; }
Property Value
Type | Description |
---|---|
T |
Methods
SetSingletonInstanceTemplateSource(AudioSource)
Call this before the first use of Instance to have the singleton instance
copy UnityEngine.AudioSource fields from templateSource
.
Declaration
public static void SetSingletonInstanceTemplateSource(AudioSource templateSource)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.AudioSource |
templateSource |
Remarks
Singleton instance is convenient but you cannot pre-connect TemplateSource like a regular instance because it does not exist until runtime.
If you had already used the singleton instance before calling this, you can still call ApplyAudioSource(AudioSource) on the singleton instance to apply different settings of UnityEngine.AudioSource.