private void SetSelected() { if (m_CurrentlySelected != null) { m_CurrentlySelected.SetSelected(false); } // in the event that another player picks the character you have selected // we need to put the index back in range when that character is removed if (m_ActiveIndex >= m_ListItems.Count) { m_ActiveIndex = m_ListItems.Count - 1; } m_CurrentlySelected = m_ListItems[m_ActiveIndex]; m_CurrentlySelected.SetSelected(true); }
public void SetData(List <UILobbyCharacterProgress> characterData) { EmptyList(); for (int i = 0; i < characterData.Count; i++) { GameObject itemObj = (GameObject)Instantiate(m_ScrollItemPrefab, m_ScrollContent); UIScrollViewItem scrollItem = itemObj.GetComponent <UIScrollViewItem>(); if (scrollItem != null) { scrollItem.SetData(characterData[i].Progress.m_Stats.PlayerName, null, characterData[i].AssignedToPlayer); // eventually pass the icon sprite in here } else { Debug.LogErrorFormat("UIScrollViewItem is missing the script!"); } m_ListItems.Add(scrollItem); } SetSelected(); }