public void RefreshProgramList() { isDisplayingPlugins = false; scrollIndex = 0; foreach (MissionPrepMenuItem listItem in displayedElements) { Destroy(listItem.gameObject); } displayedElements.Clear(); int i = scrollIndex; while (i < scrollIndex + programAnchors.Length && i < PersistentState.instance.GetOwnedPrograms().Count) { MissionPrepMenuItem newListItem = Instantiate(menuItem, programAnchors[i - scrollIndex].transform).GetComponent <MissionPrepMenuItem>(); newListItem.SetProgram(PersistentState.instance.GetOwnedPrograms()[i]); displayedElements.Add(newListItem); i++; } UpdateScrollEnabled(); }
public void ScrollRight() { for (int i = 1; i < programAnchors.Length; i++) { displayedElements[i].transform.position = programAnchors[i - 1].transform.position; } MissionPrepMenuItem temp = displayedElements[0]; displayedElements.Remove(temp); Destroy(temp.gameObject); scrollIndex++; MissionPrepMenuItem newListItem = Instantiate(menuItem, programAnchors[programAnchors.Length - 1].transform).GetComponent <MissionPrepMenuItem>(); if (isDisplayingPlugins) { newListItem.SetPlugin(PersistentState.instance.GetOwnedPlugins()[scrollIndex + programAnchors.Length - 1]); } else { newListItem.SetProgram(PersistentState.instance.GetOwnedPrograms()[scrollIndex + programAnchors.Length - 1]); } displayedElements.Add(newListItem); UpdateScrollEnabled(); }