Exemplo n.º 1
0
        private void onFlightReady()
        {
            if (!buttonInit)
            {
                modebuttons = FindObjectOfType <VesselAutopilotUI>().modeButtons;
                modebuttons[0].getSpriteStates(out buttonActive, out buttonDisabled);

                foreach (UIStateToggleButton button in modebuttons)
                {
                    button.onClick.AddListener(delegate { onSASbuttonPressed(button); });
                }

                GameObject parallelNegative = Instantiate(modebuttons[5].gameObject);
                GameObject parallelPlus     = Instantiate(modebuttons[5].gameObject);

                parallelNegative.SetActive(true);
                parallelPlus.SetActive(true);

                this.parallelNegative = parallelNegative.GetComponent <UIStateToggleButton>();
                this.parallelNegative.onClick.RemoveAllListeners();
                this.parallelNegative.onClick.AddListener(delegate { onToggleButtonPressed(this.parallelNegative); });
                this.parallelNegative.stateTrue  = buttonActive;
                this.parallelNegative.stateFalse = buttonDisabled;
                this.parallelNegative.name       = "ParallelNegative";
                this.parallelNegative.SetState(false);
                this.parallelNegative.interactable         = false;
                this.parallelNegative.transform.position   = modebuttons[7].transform.position;
                this.parallelNegative.transform.localScale = new Vector3(1 * GameSettings.UI_SCALE * GameSettings.UI_SCALE_NAVBALL, 1 * GameSettings.UI_SCALE * GameSettings.UI_SCALE_NAVBALL);
                this.parallelNegative.transform.position   = new Vector3(parallelNegative.gameObject.transform.position.x + ((4 * GameSettings.UI_SCALE_NAVBALL) * GameSettings.UI_SCALE), parallelNegative.gameObject.transform.position.y - ((25 * GameSettings.UI_SCALE_NAVBALL) * GameSettings.UI_SCALE));

                this.parallelPlus = parallelPlus.GetComponent <UIStateToggleButton>();
                this.parallelPlus.onClick.RemoveAllListeners();
                this.parallelPlus.onClick.AddListener(delegate { onToggleButtonPressed(this.parallelPlus); });
                this.parallelPlus.stateTrue  = buttonActive;
                this.parallelPlus.stateFalse = buttonDisabled;
                this.parallelPlus.name       = "ParallelPlus";
                this.parallelPlus.SetState(false);
                this.parallelPlus.interactable         = false;
                this.parallelPlus.transform.position   = modebuttons[8].transform.position;
                this.parallelPlus.transform.localScale = new Vector3(1 * GameSettings.UI_SCALE * GameSettings.UI_SCALE_NAVBALL, 1 * GameSettings.UI_SCALE * GameSettings.UI_SCALE_NAVBALL);
                this.parallelPlus.transform.position   = new Vector3(parallelPlus.gameObject.transform.position.x + ((4 * GameSettings.UI_SCALE_NAVBALL) * GameSettings.UI_SCALE), parallelPlus.gameObject.transform.position.y - ((25 * GameSettings.UI_SCALE_NAVBALL) * GameSettings.UI_SCALE));

                parallelNegative.GetComponent <TooltipController_Text>().textString = "Parallel -";
                parallelNegative.GetChild("Image").GetComponent <Image>().sprite    = AssetLoader.parallelMinus.toSprite();
                parallelNegative.transform.SetParent(UnityEngine.Object.FindObjectOfType <VesselAutopilotUI>().transform);
                parallelPlus.GetComponent <TooltipController_Text>().textString = "Parallel +";
                parallelPlus.GetChild("Image").GetComponent <Image>().sprite    = AssetLoader.parallelPlus.toSprite();
                parallelPlus.transform.SetParent(UnityEngine.Object.FindObjectOfType <VesselAutopilotUI>().transform);

                buttonInit = true;

                Debug.Log($"[{DISPLAYNAME}] UI initiated");
            }

            vessel = FlightGlobals.ActiveVessel;
            SetNewState(false, true);
        }
Exemplo n.º 2
0
        internal static void SetColor(this UIStateToggleButton toggle, Color?color, UIStateToggleButton stockButton = null)
        {
            Image image = toggle?.GetComponent <Image>();

            if (image != null && color != null)
            {
                Image stockImage = stockButton?.GetComponent <Image>();
                image.SetColor(color, stockImage);
            }
        }