mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-03-22 01:34:22 -05:00
59 lines
1.0 KiB
C#
59 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class AudioHandler : MonoBehaviour
|
|
{
|
|
|
|
public AudioSource mainTheme;
|
|
|
|
|
|
public static AudioHandler Instance => instance;
|
|
private static AudioHandler instance;
|
|
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance != null && instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
|
|
instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
public void Play()
|
|
{
|
|
if(mainTheme != null) mainTheme.Play();
|
|
}
|
|
|
|
void Stop()
|
|
{
|
|
if(mainTheme != null) mainTheme.Stop();
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
Play();
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
|
|
if (SceneManager.GetActiveScene().buildIndex == 3 || SceneManager.GetActiveScene().buildIndex == 4)
|
|
{
|
|
Stop();
|
|
}
|
|
|
|
|
|
}
|
|
}
|