Beispiel #1
0
 public void ReloadUI()
 {
     if (_ui != null)
     {
         MonoBehaviour.Destroy(_ui);
         _ui = _gameObject.AddComponent <MusicUI>();
     }
 }
Beispiel #2
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);

            //ensure it!
            ensureComponents();

            //Reload music
            _music.LoadMusicFiles();

            //Create ui
            if (_ui == null)
            {
                _ui = _gameObject.AddComponent <MusicUI>();
            }
        }
Beispiel #3
0
        public override void OnLevelUnloading()
        {
            if (_gameObject != null)
            {
                MonoBehaviour.Destroy(_gameObject);
            }
            if (_injector != null)
            {
                MonoBehaviour.Destroy(_injector);
            }
            if (_ui != null)
            {
                MonoBehaviour.Destroy(_ui);
            }

            _gameObject = null;
            _injector   = null;
            _ui         = null;

            base.OnLevelUnloading();
        }
Beispiel #4
0
 public override void OnReleased()
 {
     base.OnReleased();
     if (UI != null)
     {
         UnityEngine.Object.Destroy(UI.gameObject);
         UI = null;
     }
     if (UIShortcutHandler != null)
     {
         UnityEngine.Object.Destroy(UI.gameObject);
         UIShortcutHandler = null;
     }
     if (StationContainer != null)
     {
         UnityEngine.Object.Destroy(StationContainer.gameObject);
         StationContainer = null;
     }
     if (ContentContainer != null)
     {
         UnityEngine.Object.Destroy(ContentContainer.gameObject);
         ContentContainer = null;
     }
     if (MethodDetours != null)
     {
         UnityEngine.Object.Destroy(MethodDetours.gameObject);
         MethodDetours = null;
     }
     if (UserRadioContainer != null)
     {
         UnityEngine.Object.Destroy(UserRadioContainer.gameObject);
         UserRadioContainer = null;
     }
     if (DisabledContentContainer != null)
     {
         UnityEngine.Object.Destroy(DisabledContentContainer.gameObject);
         UserRadioContainer = null;
     }
 }
Beispiel #5
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);

            CSLMusicMod.Log("Got OnLevelLoaded: " + mode);

            if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame || mode == LoadMode.NewGameFromScenario)
            {
                CSLMusicMod.Log("Level loaded. Loading mod components.");

                RemoveUnsupportedContent();
                UserRadioContainer.CollectPostLoadingData();
                ExtendVanillaContent();

                // Build UI and other post loadtime
                if (UI == null && ModOptions.Instance.EnableCustomUI)
                {
                    UI = new GameObject("CSLMusicMod_UI").AddComponent <MusicUI>();
                }
                if (UIShortcutHandler == null && ModOptions.Instance.EnableShortcuts)
                {
                    UIShortcutHandler = new GameObject("CSLMusicMod_UIShortcutHandler").AddComponent <ShortcutHandler>();
                }
                if (DisabledContentContainer == null)
                {
                    DisabledContentContainer = new GameObject("CSLMusicMod_DisabledContent").AddComponent <RadioContentWatcher>();
                }

                try
                {
                    DebugOutput();
                }
                catch (Exception ex)
                {
                    Debug.LogError("[CSLMusic] DebugOutput Error: " + ex);
                }
            }
        }