private void OnRefreshChange(UIStateButton button) { if (_settings.autoRefresh) { _autoRefreshState = button.currentState; } }
private void OnOverylayChange(UIStateButton button) { if (_settings.rememberOverlay) { _visibilityMode = button.currentState; } }
new public static UIStateButton create(UIToolkit manager, string filename, string highlightedFilename, int xPos, int yPos, int depth) { var filenames = new string[1] { filename }; var highlightedFilenames = new string[1] { highlightedFilename }; return(UIStateButton.create(manager, filenames, highlightedFilenames, xPos, yPos, depth)); }
void Start() { var filenames = new string[] { "playUp.png", "scoresUp.png", "optionsUp.png" }; var highlightedFilenames = new string[] { "playDown.png", "scoresDown.png", "optionsDown.png" }; var stateButton = UIStateButton.create(filenames, highlightedFilenames, 0, 0); stateButton.positionCenter(); stateButton.onStateChange += onStateChange; // can hook up to UIButton events too stateButton.onTouchUpInside += onButtonTouched; }
private void OnModeChange(UIStateButton button) { string mode = button.currentState; if (!_kerbnets.ContainsKey(mode)) { return; } _currentMode = mode; UpdateValues(mode); if (_dialog != null) { UpdateDisplay(); } }
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); } }
public static UIStateButton create( UIToolkit manager, string[] filenames, string[] highlightedFilenames, int xPos, int yPos, int depth ) { // grab the texture details for the initial state var firstNormalTI = manager.textureInfoForFilename( filenames[0] ); var frame = new Rect( xPos, yPos, firstNormalTI.frame.width, firstNormalTI.frame.height ); // get the initial highlighted state var firstHighlightedTI = firstNormalTI; if (highlightedFilenames.Length > 0) { manager.textureInfoForFilename( highlightedFilenames[0] ); } var button = new UIStateButton( manager, frame, depth, firstNormalTI.uvRect, firstHighlightedTI.uvRect ); button.addFrames(filenames, highlightedFilenames); return button; }
public static UIStateButton create(UIToolkit manager, string[] filenames, string[] highlightedFilenames, int xPos, int yPos, int depth) { // grab the texture details for the initial state var firstNormalTI = manager.textureInfoForFilename(filenames[0]); var frame = new Rect(xPos, yPos, firstNormalTI.frame.width, firstNormalTI.frame.height); // get the initial highlighted state var firstHighlightedTI = firstNormalTI; if (highlightedFilenames.Length > 0) { manager.textureInfoForFilename(highlightedFilenames[0]); } var button = new UIStateButton(manager, frame, depth, firstNormalTI.uvRect, firstHighlightedTI.uvRect); button.addFrames(filenames, highlightedFilenames); return(button); }
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 OnOrientationChange(UIStateButton button) { if (!_settings.orientationButton) { return; } if (button.currentState == "north_up") { GameSettings.KERBNET_ALIGNS_WITH_ORBIT = false; } else if (button.currentState == "orbit_up") { GameSettings.KERBNET_ALIGNS_WITH_ORBIT = true; } if (_dialog != null) { UpdateDisplay(); } }
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); } }
internal static void Find(bool clean = false) { List <RDNode> _nodes = RDController.Instance.nodes; for (int _i = _nodes.Count - 1; _i >= 0; --_i) { RDNode _node = _nodes[_i]; RDTech _rdTech = _node.tech; if (_node.graphics != null) { UIStateButton _button = _node.graphics.button; if (!clean && _rdTech.partsAssigned.Find(aPart => QSearch.FindPart(aPart)) != null) { _button.Image.color = new Color(1f, 0f, 0f); continue; } _button.Image.color = new Color(1f, 1f, 1f); } } //QDebug.Log ("Find: " + QSearch.Text, "QRnD"); }
public static UIStateButton create(UIToolkit manager, string[] filenames, string[] highlightedFilenames, int xPos, int yPos) { return(UIStateButton.create(manager, filenames, highlightedFilenames, xPos, yPos, 1)); }
public static UIStateButton create(string[] filenames, string[] highlightedFilenames, int xPos, int yPos) { return(UIStateButton.create(UI.firstToolkit, filenames, highlightedFilenames, xPos, yPos)); }
private void onStateChange( UIStateButton sender, int state ) { Debug.Log( "Button is at state: " + state ); }
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)); }
private void onStateChange(UIStateButton sender, int state) { Debug.Log("Button is at state: " + state); }