private void updateItem(int index, GameObject item) { item.SetActive(index < m_Datas.Count); if (item.activeSelf) { UILoopItem lit = item.GetComponent <UILoopItem>(); lit.UpdateItem(index, item); lit.Data(m_Datas[index]); if (selectedObject == m_Datas[index]) { lit.SetSelected(true); } else { lit.SetSelected(false); } if (lit.GetComponent <Button>() != null && addClickEventList.IndexOf(lit.GetComponent <Button>()) < 0) { addClickEventList.Add(lit.GetComponent <Button>()); lit.GetComponent <Button>().onClick.AddListener( delegate(){ if (selectedItem != null && selectedItem != item.GetComponent <UILoopItem>()) { selectedItem.SetSelected(false); } selectedItem = item.GetComponent <UILoopItem>(); selectedObject = selectedItem.GetData(); selectedItem.SetSelected(true); selectedItem.OnSelectedEventHandler(); } ); } } }
private void updateItem(int index, GameObject item) { item.SetActive(index < m_Datas.Count); if (item.activeSelf) { UILoopItem lit = item.GetComponent <UILoopItem>(); lit.UpdateItem(index, item); lit.Data(m_Datas[index]); } }