using System.Collections.Generic; using BitStrap; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class EquipmentCategoryButton : MonoBehaviour { public List childButtons = new List(); public Image arrowImage; public Image separatorImage; public Text nameText; public bool expandAtStart; [ReadOnly] public bool isExpanded; private EquipmentGUI equipmentGUI; private void OnEnable() { if (equipmentGUI != null) { Expand(false); } } private void Start() { equipmentGUI = Object.FindObjectOfType(); isExpanded = !expandAtStart; Expand(expandAtStart); } public void ToggleExpand() { Expand(!isExpanded); } public void Expand(bool expand) { if (expand == isExpanded) { return; } for (int i = 0; i < childButtons.Count; i++) { if ((equipmentGUI.isIceEquipment || !equipmentGUI.tabsOnlyIce.Contains(childButtons[i]) || !expand) && (!equipmentGUI.isIceEquipment || !equipmentGUI.tabsOnlyNormal.Contains(childButtons[i]) || !expand)) { childButtons[i].SetActive(expand); } } arrowImage.rectTransform.localScale = new Vector3((!expand) ? 1f : (-1f), 1f, 1f); arrowImage.enabled = expand; if ((bool)separatorImage) { separatorImage.enabled = expand; } if ((bool)nameText) { nameText.rectTransform.anchoredPosition = new Vector2((!expand) ? 0f : 23f, 0f); } if (EventSystem.current != null) { EventSystem.current.SetSelectedGameObject(null); } base.transform.parent.GetComponent().Refresh(); isExpanded = expand; } }