35 lines
749 B
C#
35 lines
749 B
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class MenuMusic : MonoBehaviour
|
|
{
|
|
public static MenuMusic Instance;
|
|
|
|
void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
SceneManager.sceneLoaded += OnSceneLoaded;
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
GetComponent<AudioSource>().volume = BazookaManager.Instance.GetSettingMusicVolume();
|
|
}
|
|
|
|
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
|
{
|
|
if (scene.name == "GamePlayer")
|
|
{
|
|
SceneManager.sceneLoaded -= OnSceneLoaded;
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
} |