using System.Collections; using System.Collections.Generic; using UnityEngine; public class SelctedGroup : MonoBehaviour { private Transform[] options; public GameObject ItemList1, ItemList2, ItemList3, ItemList4; public GameObject SelectedEffect1, SelectedEffect2, SelectedEffect3, SelectedEffect4; public SelctedItem[] selctedItems; public SelctedItem CurrentItem; private void Start() { options = new Transform[transform.childCount]; selctedItems =new SelctedItem[transform.childCount]; for (int i = 0; i < transform.childCount; i++) { options[i] = transform.GetChild(i); SelctedItem item= options[i].gameObject.AddComponent(); selctedItems[i] = item; item.selctedGroup = this; item.ItemIndex = i + 1; item.Init(); } ItemList1.SetActive(false); ItemList2.SetActive(false); ItemList3.SetActive(false); ItemList4.SetActive(false); } public void ResetItemList() { ItemList1.SetActive(false); ItemList2.SetActive(false); ItemList3.SetActive(false); ItemList4.SetActive(false); SelectedEffect1.SetActive(false); SelectedEffect2.SetActive(false); SelectedEffect3.SetActive(false); SelectedEffect4.SetActive(false); //for (int i = 0; i < selctedItems.Length; i++) //{ // selctedItems[i].isOpen = false; //} } public void ShowItemList (int index) { ResetItemList(); switch (index) { case 1: ItemList1.SetActive(true); SelectedEffect1.SetActive(true); break; case 2: ItemList2.SetActive(true); SelectedEffect2.SetActive(true); break; case 3: ItemList3.SetActive(true); SelectedEffect3.SetActive(true); break; case 4: ItemList4.SetActive(true); SelectedEffect4.SetActive(true); break; } } }