protected override void CreateItems() { base.CreateItems(); float runningPosition = 0f; for (int index = 1; index <= ConfigModel.Instance.GetWorldsConfig().Count; index++) { WorldConfig worldConfig = ConfigModel.Instance.GetWorldConfigForID(index); GameObject childListItem = Instantiate <GameObject>(listItem); childListItem.transform.SetParent(holder); childListItem.transform.localScale = Vector3.one; childListItem.transform.localPosition = new Vector3(runningPosition, 0f, 0); runningPosition += itemWidth + space; IListItem iListItem = childListItem.GetComponent <IListItem>(); iListItem.UpdateListItem(worldConfig); items.Add(iListItem); } for (int index = 0; index < items.Count; index++) { WorldSelectionItem wsItem = items[index] as WorldSelectionItem; wsItem.playBtn2.onClick.AddListener(() => { SelectWorld(wsItem); }); wsItem.unlockBtn.onClick.AddListener(() => { if (GameModel.Instance.diamondCount >= wsItem._data.diamondsRequired) { GameModel.Instance.lastUnlockedWorldId = wsItem._data.id; GameModel.Instance.activeWorldId = wsItem._data.id; Events.instance.Raise(new UpdateDiamondEvent(-wsItem._data.diamondsRequired, true)); SaveDataModel.Instance.SaveToDisk(); UpdateAll(); } }); } }