public void ClearSelection() { GameObject[] array = buttonObjects; foreach (GameObject gameObject in array) { KToggle component = gameObject.GetComponent <KToggle>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { component.Deselect(); component.isOn = false; } else { KBasicToggle component2 = gameObject.GetComponent <KBasicToggle>(); if ((UnityEngine.Object)component2 != (UnityEngine.Object)null) { component2.isOn = false; } } ImageToggleState component3 = gameObject.GetComponent <ImageToggleState>(); if (component3.GetIsActive()) { component3.SetInactive(); } } ToggleGroup component4 = GetComponent <ToggleGroup>(); if ((UnityEngine.Object)component4 != (UnityEngine.Object)null) { component4.SetAllTogglesOff(); } SelectToggle(null); }
public virtual void RefreshButtons() { if (buttonObjects != null) { for (int i = 0; i < buttonObjects.Length; i++) { UnityEngine.Object.Destroy(buttonObjects[i]); } buttonObjects = null; } if (buttons != null && buttons.Count != 0) { buttonObjects = new GameObject[buttons.Count]; for (int j = 0; j < buttons.Count; j++) { ButtonInfo buttonInfo = buttons[j]; if (buttonInfo != null) { GameObject binstance = UnityEngine.Object.Instantiate(buttonPrefab, Vector3.zero, Quaternion.identity); buttonInfo.buttonGo = binstance; buttonObjects[j] = binstance; Transform transform = null; transform = ((!((UnityEngine.Object)buttonParent != (UnityEngine.Object)null)) ? base.transform : buttonParent); binstance.transform.SetParent(transform, false); binstance.SetActive(true); binstance.name = buttonInfo.text + "Button"; KButton component = binstance.GetComponent <KButton>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null && buttonInfo.onClick != null) { component.onClick += buttonInfo.onClick; } Image image = null; if ((bool)component) { image = component.fgImage; } if ((UnityEngine.Object)image != (UnityEngine.Object)null) { image.gameObject.SetActive(false); Sprite[] array = icons; foreach (Sprite sprite in array) { if ((UnityEngine.Object)sprite != (UnityEngine.Object)null && sprite.name == buttonInfo.iconName) { image.sprite = sprite; image.gameObject.SetActive(true); break; } } } if ((UnityEngine.Object)buttonInfo.texture != (UnityEngine.Object)null) { RawImage componentInChildren = binstance.GetComponentInChildren <RawImage>(); if ((UnityEngine.Object)componentInChildren != (UnityEngine.Object)null) { componentInChildren.gameObject.SetActive(true); componentInChildren.texture = buttonInfo.texture; } } ToolTip componentInChildren2 = binstance.GetComponentInChildren <ToolTip>(); if (buttonInfo.text != null && buttonInfo.text != string.Empty && (UnityEngine.Object)componentInChildren2 != (UnityEngine.Object)null) { componentInChildren2.toolTip = buttonInfo.GetTooltipText(); LocText componentInChildren3 = binstance.GetComponentInChildren <LocText>(); if ((UnityEngine.Object)componentInChildren3 != (UnityEngine.Object)null) { componentInChildren3.text = buttonInfo.text; } } if (buttonInfo.onToolTip != null) { componentInChildren2.OnToolTip = buttonInfo.onToolTip; } System.Action onClick = buttonInfo.onClick; System.Action value = delegate { onClick.Signal(); if (!keepMenuOpen && (UnityEngine.Object) this != (UnityEngine.Object)null) { Deactivate(); } if ((UnityEngine.Object)binstance != (UnityEngine.Object)null) { KToggle component3 = binstance.GetComponent <KToggle>(); if ((UnityEngine.Object)component3 != (UnityEngine.Object)null) { SelectToggle(component3); } } }; KToggle componentInChildren4 = binstance.GetComponentInChildren <KToggle>(); if ((UnityEngine.Object)componentInChildren4 != (UnityEngine.Object)null) { componentInChildren4.onRefresh += buttonInfo.onRefresh; ToggleGroup component2 = GetComponent <ToggleGroup>(); if ((UnityEngine.Object)component2 == (UnityEngine.Object)null) { component2 = externalToggleGroup; } componentInChildren4.group = component2; componentInChildren4.onClick += value; Navigation navigation = componentInChildren4.navigation; navigation.mode = (automaticNavigation ? Navigation.Mode.Automatic : Navigation.Mode.None); componentInChildren4.navigation = navigation; } else { KBasicToggle componentInChildren5 = binstance.GetComponentInChildren <KBasicToggle>(); if ((UnityEngine.Object)componentInChildren5 != (UnityEngine.Object)null) { componentInChildren5.onClick += value; } } if ((UnityEngine.Object)component != (UnityEngine.Object)null) { component.isInteractable = buttonInfo.isInteractable; } buttonInfo.onCreate.Signal(buttonInfo); } } Update(); } }