internal void Awake() { try { if (HighLogic.LoadedScene != GameScenes.SPACECENTER && HighLogic.LoadedScene != GameScenes.FLIGHT) { return; } DontDestroyOnLoad(this); LtSettings.LoadSettings(); // Added support for Blizzy toolbar and hot switching between Stock and Blizzy CreateAppIcons(); } catch (Exception ex) { Util.LogMessage("LTAddon.Awake. Error: " + ex, Util.LogType.Error); } }
internal void OnDestroy() { try { if (LtSettings.loaded) { LtSettings.SaveSettings(); } GameEvents.onGameSceneSwitchRequested.Remove(OnGameSceneSwitchRequested); GameEvents.onGameSceneLoadRequested.Remove(OnGameSceneLoadRequested); GameEvents.onShowUI.Remove(OnShowUi); GameEvents.onHideUI.Remove(OnHideUi); // Handle toolbars DestroyAppIcons(); } catch (Exception ex) { Util.LogMessage("LTAddon.OnDestroy. Error: " + ex, Util.LogType.Error); } }
// Save settings on scene changes private void OnGameSceneLoadRequested(GameScenes requestedScene) { LtSettings.SaveSettings(); }