// -------------------------------------------------------------------------------------------------------------------- // // Part of: Pun Cockpit // // developer@exitgames.com // -------------------------------------------------------------------------------------------------------------------- using System.Collections.Generic; using UnityEngine; using Photon.Realtime; namespace Photon.Pun.Demo.Cockpit { /// /// Region list UI View. /// public class RegionListView : MonoBehaviour { public RegionListCell CellPrototype; Dictionary regionCellList = new Dictionary(); public void OnEnable() { ResetList(); CellPrototype.gameObject.SetActive(false); } public void OnRegionListUpdate(List regionList) { int i = 0; foreach (Region entry in regionList) { // we create the cell regionCellList[entry.Code] = Instantiate(CellPrototype); regionCellList[entry.Code].gameObject.SetActive(true); regionCellList[entry.Code].transform.SetParent(CellPrototype.transform.parent, false); regionCellList[entry.Code].AddToList(entry,i); i++; } } public void ResetList() { foreach (KeyValuePair entry in regionCellList) { if (entry.Value != null) { Destroy(entry.Value.gameObject); } } regionCellList = new Dictionary(); } } }