//---------------------- // Private Variables //---------------------- // Protected Variables //======================================== // setter / getter //------------------------------ //======================================== // Unity's function //------------------------------ protected override void Awake() { base.Awake(); // NOTE(jenchieh): Only the first time will call this. // This game object is a unique game object. Meaning the // object itself uses 'DontDestroyOnLoad' function. if (instance == null) { instance = this; // ==> OnLevelWasLoaded <== UnityEngine.SceneManagement.SceneManager.sceneLoaded += (scene, loadingMode) => { // set to Sound Manager in order to get manage JCS_SoundManager.instance.SetBackgroundMusic(GetAudioSource()); if (!JCS_SoundSettings.instance.KEEP_BGM_SWITCH_SCENE) { // Assign BGM from Sound Manager! GetAudioSource().clip = JCS_SoundSettings.instance.BACKGROUND_MUSIC; GetAudioSource().Play(); } }; } else { if (instance != this) { Destroy(this.gameObject); } } }
protected override void Awake() { base.Awake(); // NOTE(jenchieh): Only the first time will call this. // This game object is a unique game object. Meaning the // object itself uses 'DontDestroyOnLoad' function. if (instance == null) { instance = this; #if UNITY_5_4_OR_NEWER // ==> OnLevelWasLoaded <== SceneManager.sceneLoaded += (scene, loadingMode) => { LevelLoaded(); }; #endif } else { if (instance != this) { Destroy(this.gameObject); } } }