mirror of
https://github.com/appen-isen/jeu-sans-image.git
synced 2026-03-18 21:50:42 +01:00
46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// The music manager is responsible for handling loopable sounds.
|
|
/// If you want to manage a non-looped sound, use the SoundManager.
|
|
/// </summary>
|
|
public class MusicManager : MonoBehaviour
|
|
{
|
|
// Singleton pattern
|
|
[System.NonSerialized] public static MusicManager Instance = null;
|
|
|
|
private void Awake()
|
|
{
|
|
// Singleton pattern
|
|
if (Instance != null && Instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
else
|
|
{
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
}
|
|
|
|
public void StartMusic(ILoopableSound music)
|
|
{
|
|
music.PlayLoopableSound(transform, false);
|
|
}
|
|
|
|
public void StartMusic(ILoopableSound music, Vector3 position)
|
|
{
|
|
music.PlayLoopableSound(position);
|
|
}
|
|
|
|
public void StartMusic(ILoopableSound music, Transform parent)
|
|
{
|
|
music.PlayLoopableSound(parent, true);
|
|
}
|
|
|
|
public void StopMusic(ILoopableSound music)
|
|
{
|
|
music.StopLoopableSound();
|
|
}
|
|
}
|