You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
754 B

using UnityEngine;
public class BackgroundManager : MonoBehaviour
{
private static AudioSource audioSource;
public AudioClip BG;
private void Awake()
{
audioSource = GetComponent<AudioSource>();
}
void Start()
{
if (BG != null)
{
PlayBG(false,BG);
}
}
public static void PlayBG(bool resetSong, AudioClip clip = null)
{
if (clip != null)
{
audioSource.clip = clip;
}
if (audioSource.clip != null)
{
if (resetSong)
{
audioSource.Stop();
}
audioSource.Play();
}
}
public static void StopBG()
{
audioSource.Pause();
}
}