private void AddModeListener()
        {
            if (_dialog == null)
            {
                return;
            }

            _stateButtons = _dialog.GetComponentsInChildren <UIStateButton>(true);

            UIStateButton modeButton = _stateButtons[0];

            modeButton.onValueChanged.AddListener(new UnityAction <UIStateButton>(OnModeChange));

            if (_settings.rememberMode && !string.IsNullOrEmpty(_currentMode))
            {
                modeButton.SetState(_currentMode, true);
            }
        }
        private void SetAutoRefreshListener()
        {
            if (_dialog == null)
            {
                return;
            }

            if (_stateButtons == null)
            {
                return;
            }

            UIStateButton refreshButton = _stateButtons[2];

            refreshButton.onValueChanged.AddListener(new UnityAction <UIStateButton>(OnRefreshChange));

            if (!string.IsNullOrEmpty(_autoRefreshState))
            {
                refreshButton.SetState(_autoRefreshState, true);
            }
        }
        private void SetOverlayListener()
        {
            if (_dialog == null)
            {
                return;
            }

            if (_stateButtons == null)
            {
                return;
            }

            UIStateButton overlayButton = _stateButtons[1];

            overlayButton.onValueChanged.AddListener(new UnityAction <UIStateButton>(OnOverylayChange));

            if (!string.IsNullOrEmpty(_visibilityMode))
            {
                overlayButton.SetState(_visibilityMode, true);
            }
        }
        private void SetOrientationButton()
        {
            if (_dialog == null)
            {
                return;
            }

            if (_stateButtons == null)
            {
                return;
            }

            UIStateButton refreshButton = _stateButtons[2];

            GameObject parent = refreshButton.transform.parent.gameObject;

            GameObject outline = MonoBehaviour.Instantiate(parent, parent.transform.parent) as GameObject;

            outline.name = "Outline_Orientation";

            FieldInfo disableField = typeof(KerbNetDialog).GetField("disableOnError", BindingFlags.NonPublic | BindingFlags.Instance);

            var disableObjects = disableField.GetValue(_dialog) as GameObject[];

            if (disableObjects != null)
            {
                List <GameObject> disableList = disableObjects.ToList();

                disableList.Add(outline);

                disableField.SetValue(_dialog, disableList.ToArray());
            }

            GameObject child = outline.GetChild("Button_Auto_Refresh");

            if (child != null)
            {
                child.transform.SetParent(null);
                MonoBehaviour.DestroyImmediate(child);
            }

            _orientButton = MonoBehaviour.Instantiate(refreshButton, outline.transform) as UIStateButton;

            _orientButton.name = "Button_Orientation";

            RectTransform rect = outline.GetComponent <RectTransform>();

            if (rect != null)
            {
                rect.anchoredPosition = new Vector2(rect.anchoredPosition.x + rect.rect.width, rect.anchoredPosition.y);
            }

            TooltipController_Text tooltip = outline.GetComponentInChildren <TooltipController_Text>();

            if (tooltip != null)
            {
                tooltip.textString = "Toggle Map Orientation";
            }

            _orientButton.states = new ButtonState[]
            {
                new ButtonState()
                {
                    name = "north_up", normal = _northSprite
                },
                new ButtonState()
                {
                    name = "orbit_up", normal = _orbitSprite
                }
            };

            _orientButton.SetState(GameSettings.KERBNET_ALIGNS_WITH_ORBIT ? "orbit_up" : "north_up", false);

            _orientButton.onValueChanged.AddListener(new UnityAction <UIStateButton>(OnOrientationChange));
        }