31 lines
651 B
C#
31 lines
651 B
C#
using UnityEngine;
|
|
|
|
public class AudioManager : MonoBehaviour
|
|
{
|
|
private AudioSource backgroundSource;
|
|
public static AudioManager Instance { get; private set; }
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
backgroundSource = GetComponent<AudioSource>();
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
public void PlayBackgroundMusic(string trackName)
|
|
{
|
|
// Logic to play background music
|
|
}
|
|
|
|
public void StopBackgroundMusic()
|
|
{
|
|
backgroundSource.Stop();
|
|
}
|
|
} |