void refresh() { List <SavedTopologyData> topologiesData = SaveManager.Instance.GetSavedTopologies(); for (int i = 0; i < topologiesData.Count; i++) { if (i >= topologies.Count) { createNewTopologyListElement(); } topologies [i].Setup(topologiesData [i]); } int diff = topologies.Count - topologiesData.Count; if (diff > 0) { for (int i = 0; i < diff; i++) { deleteLastListElement(); } } if (currentSelected != null) { currentSelected.Deselect(); } currentSelected = null; refreshButtons(); StartCoroutine(resetScrollRectVerticalNormalizedPosition()); }
void createNewTopologyListElement() { GameObject newGameObject = Instantiate(listElementPrefab); newGameObject.SetActive(true); newGameObject.transform.SetParent(listElementContainer, false); SavedTopologyListElement savedTopologyListElement = newGameObject.GetComponent <SavedTopologyListElement> (); savedTopologyListElement.OnClick += onListElementClicked; topologies.Add(savedTopologyListElement); }
void onListElementClicked(SavedTopologyListElement savedTopologyListElement) { for (int i = 0; i < topologies.Count; i++) { if (savedTopologyListElement == topologies [i]) { topologies [i].Select(); } else { topologies [i].Deselect(); } } currentSelected = savedTopologyListElement; refreshButtons(); }