Пример #1
0
        /// <summary>Creates a toolbar button for KSP's toolbar</summary>
        void InitToolbarButton()
        {
            Debug.Log("[Kerbulator] InitToolbarButton");
            if (!ApplicationLauncher.Ready || mainButton != null)
            {
                return;
            }

            Debug.Log("[Kerbulator] AddModApplication");
            mainButton = ApplicationLauncher.Instance.AddModApplication(
                // Callback when enabled
                () => {
                gui.ChangeState(true);
            },

                // Callback when disabled
                () => {
                gui.ChangeState(false);
            },

                // Unused callbacks
                null,
                null,
                null,
                null,

                // Visible in these scenes
                ApplicationLauncher.AppScenes.ALWAYS,

                // Button texture
                GetTexture("kerbulator_38")
                );

            Debug.Log("[Kerbulator] Done!");
        }
Пример #2
0
        /// <summary>Called by Unity when the Plugin is started</summary>
        void Start()
        {
            if (ToolbarManager.ToolbarAvailable)
            {
                mainWindowEnabled      = false;
                mainButton             = ToolbarManager.Instance.add("Kerbulator", "Kerbulator");
                mainButton.TexturePath = "Kerbulator/Textures/kerbulator";
                mainButton.ToolTip     = "Open a powerful calculator";
                mainButton.Visibility  = new GameScenesVisibility(GameScenes.FLIGHT);
                mainButton.OnClick    += (e) => {
                    gui.ChangeState(!mainWindowEnabled);
                };
            }

            gui = new KerbulatorGUI(this, false, !ToolbarManager.ToolbarAvailable);
        }