private void Awake()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                Destroy(gameObject);
                return;
            }

            if (instance != null)
            {
                Destroy(gameObject);
                return;
            }

            instance = this;

            vessels = new DictionaryValueList <Guid, SEP_VesselSection>();

            if (icon == null)
            {
                icon = GameDatabase.Instance.GetTexture("SurfaceExperimentPackage/Resources/Toolbar_Icon", false);
            }

            StartCoroutine(getVessels());

            GameEvents.onGUIApplicationLauncherReady.Add(onReady);
            GameEvents.onGUIApplicationLauncherUnreadifying.Add(onUnreadifying);
            GameEvents.OnGameSettingsApplied.Add(onSettingsApplied);
            SEP_Utilities.onExperimentActivate.Add(onExpActivate);
            SEP_Utilities.onExperimentDeactivate.Add(onExpDeactivate);
        }
Exemplo n.º 2
0
        private void OnDestroy()
        {
            instance = null;

            GameEvents.onGUIApplicationLauncherReady.Remove(onReady);
            GameEvents.onGUIApplicationLauncherUnreadifying.Remove(onUnreadifying);
            GameEvents.OnGameSettingsApplied.Remove(onSettingsApplied);
            SEP_Utilities.onExperimentActivate.Remove(onExpActivate);
            SEP_Utilities.onExperimentDeactivate.Remove(onExpDeactivate);

            for (int i = vessels.Count - 1; i >= 0; i--)
            {
                SEP_VesselSection v = vessels.At(i);

                if (v == null)
                {
                    continue;
                }

                v.OnDestroy();
            }

            if (window != null)
            {
                Destroy(window.gameObject);
            }

            if (compactWindow != null)
            {
                Destroy(compactWindow.gameObject);
            }
        }