NAV Navbar
csharp
  • Introloop API Documentation
  • Introloop API Documentation

    Welcome! Please see the getting started guide to get a general idea of how Introloop should be used.

    IntroloopPlayer

    The main class.

    IntroloopPlayer.Instance

    Singleton pattern point of access. Get the IntroloopPlayer instance. If you have multiple subclasses of IntroloopPlayer you should use YourClass.Get instead. (See IntroloopPlayer<T>)

    IntroloopPlayer.Pause

    Stop the currently playing IntroloopAudio instantly without unloading. You will be able to use Resume() to continue later.

    IntroloopPlayer.PauseFade

    Stop the currently playing IntroloopAudio without unloading with fade length specified by default length in IntroloopSettings component. You will be able to use Resume() to continue later.

    IntroloopPlayer.PauseFade(fadeLengthSeconds)

    Stop the currently playing IntroloopAudio without unloading with fade length specified by the argument. You will be able to use Resume() to continue later.

    Name Description
    fadeLengthSeconds float
    Fade out length to use.

    IntroloopPlayer.Play(audio)

    Play an audio using settings specified in IntroloopAudio file's inspector area.

    Name Description
    audio IntroloopAudio
    An IntroloopAudio asset file to play.

    IntroloopPlayer.PlayFade(audio, fadeLengthSeconds)

    Play an audio using settings specified in IntroloopAudio file's inspector area with fade-in or cross fade (if other IntroloopAudio is playing) of length specified by argument.

    Name Description
    audio IntroloopAudio
    An IntroloopAudio asset file to play.
    fadeLengthSeconds float
    Fade in/cross fade length to use.

    IntroloopPlayer.PlayFade(audio)

    Play an audio using settings specified in IntroloopAudio file's inspector area with fade-in or cross fade (if other IntroloopAudio is playing) of default length specified in IntroloopSettings component that is attached to the IntroloopPlayer.

    Name Description
    audio IntroloopAudio
    An IntroloopAudio asset file to play.

    IntroloopPlayer.Preload(IntroloopAudio)

    An experimental feature in the case that you really want the audio to start in an instant you call Play.

    By normally using Play and Stop it loads the audio the moment you called Play. It will introduces a small delay in the case of a large audio file. But by using this before actually calling Play it will be instant.

    However be aware that RAM is managed less efficiently in the following case. Normally Introloop immediately unloads the previous track to minimize memory, but if you use Preload then did not call Play with the same IntroloopAudio afterwards, the loaded memory will be unmanaged. (Just like if you tick "Preload Audio Data" on your clip and have them in a hierarchy somewhere, then did not use it.)

    IntroloopPlayer.Resume

    Resume playing of a previously paused IntroloopAudio instantly.

    IntroloopPlayer.ResumeFade

    Resume playing of a previously paused IntroloopAudio with fade in length specified in IntroloopSettings component.

    IntroloopPlayer.ResumeFade(fadeLengthSeconds)

    Resume playing of a previously paused IntroloopAudio with fade in length specified by argument in IntroloopSettings component.

    Name Description
    fadeLengthSeconds float
    Fade out length to use.

    IntroloopPlayer.Stop

    Stop the currently playing IntroloopAudio instantly, and unload that audio from memory.

    IntroloopPlayer.StopFade

    Stop the currently playing IntroloopAudio with fade out length specified by default length in IntroloopSettings component. Unloads that audio from memory once the fade out finished.

    IntroloopPlayer.StopFade(fadeLengthSeconds)

    Stop the currently playing IntroloopAudio with fade out length specified by an argument. Unloads that audio from memory once the fade out finished.

    Name Description
    fadeLengthSeconds float
    Fade out length to use.

    IntroloopPlayer<T>

    Implement your own custom subclass like this :

    public class FieldBGMPlayer : IntroloopPlayer<FieldBGMPlayer>
    {
        public IntroloopAudio desertTheme;
        public void PlayDesertTheme(bool afterDungeon)
        {
            PlayFade(desertTheme, afterDungeon ? 4.5f : 0);
        }
    }
    

    After making FieldBGMPlayer.prefab in your Resources/Introloop folder, you can now :

    FieldBGMPlayer.Get.PlayDesertTheme(true);
    

    Note the Get. It is not Instance like IntroloopPlayer.Instance

    This is a new feature in the next V3.0 (predocumented.. sorry)

    Use this generic version for subclassing. You can then get it with YourClass.Get instead of IntroloopPlayer.Instance. Put your class itself into the T variable.

    IntroloopPlaye<T>.Get

    With Instance, it is of type IntroloopPlayer and you can feed it IntroloopAudio to play.

    With Get, you can get your own subclass of IntroloopPlayer. You can then define your own methods on them and do whatever you like, like FieldBGMPlayer.Get.PlayDesertTheme() instead of IntroloopPlayer.Instance.Play(desertTheme);

    It is useful for dividing the players into several parts. Like BGMPlayer, AmbientPlayer, etc. The difference from Instance is that Get does not support dynamic instantiation. If it could not find a template, an error will be thrown.

    The template's name was hardcoded as the same as your class name, T. If your class name is FieldBGMPlayer then you must have FieldBGMPlayer.prefab in the same location as IntroloopPlayer.prefab in Resources folder.

    IntroloopSettings

    This class should be attaced together with IntroloopPlayer on your template prefab.

    IntroloopSettings.defaultFadeLength

    Method with "Fade" and without fade time parameter will use this length.

    IntroloopSettings.defaultGameObjectName

    The first call to IntroloopPlayer.Instance will spawn a GameObject of this name in your scene.

    IntroloopSettings.defaultTemplatePathWithoutFileName

    This is the path of IntroloopPlayer template relative to Resources folder.

    IntroloopSettings.logInformation

    Check this in your IntroloopPlayer template to log various debug data.