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().volume = BazookaManager.Instance.GetSettingMusicVolume(); } void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (scene.name == "GamePlayer") { SceneManager.sceneLoaded -= OnSceneLoaded; Destroy(gameObject); } } }