public override void Start() { base.Start(); if (!PerkManager.IsEnabled()) { thisObj.SetActive(false); return; } if (PerkManager.UseRscManagerForCost()) { for (int i = 0; i < RscManager.GetResourceCount(); i++) { if (i > 0) { costItemList.Add(new UIObject(UI.Clone(costItemList[0].rootObj))); } costItemList[i].Init(); costItemList[i].imgMain.sprite = RscManager.GetRscIcon(i); } } else { costItemList[0].Init(); costItemList[0].imgMain.sprite = PerkDB.GetRscIcon(); } if (customLayout) { List <Perk> perkList = PerkManager.GetPerkList(); for (int i = 0; i < itemList.Count; i++) { itemList[i].Init(); itemList[i].SetCallback(null, null, this.OnItem, null); bool matched = false; for (int n = 0; n < perkList.Count; n++) { if (itemList[i].linkedPerkPID == perkList[n].prefabID) { itemList[i].linkedPerkIdx = n; matched = true; itemList[i].imgMain.sprite = perkList[n].icon; } } if (!matched) { Debug.LogWarning("No perk with matching prefab found"); itemList[i].rootObj.SetActive(false); continue; } itemList[i].UnparentConnector(); itemList[i].UnparentConnectorBase(); } } else { List <Perk> perkList = PerkManager.GetPerkList(); for (int i = 0; i < perkList.Count; i++) { if (i > 0) { itemList.Add(UIPerkItem.Clone(itemList[0].rootObj, "Item" + (i))); } itemList[i].Init(); itemList[i].SetCallback(null, null, this.OnItem, null); itemList[i].linkedPerkIdx = i; itemList[i].imgMain.sprite = perkList[i].icon; } } buttonPurchase.Init(); buttonPurchase.SetCallback(null, null, this.OnPurchaseButton, null); if (UIControl.IsGameScene()) { buttonClose.Init(); buttonClose.SetCallback(null, null, this.OnCloseButton, null); } if (!UIControl.IsGameScene()) { canvasGroup.alpha = 1; thisObj.SetActive(true); StartCoroutine(DelayUpdateList()); } else { thisObj.SetActive(false); } OnItem(itemList[0].rootObj); }
void Start() { if (!manuallySetupItem) { List <Perk> perkList = PerkManager.GetPerkList(); for (int i = 0; i < perkList.Count; i++) { if (i == 0) { perkItemList[0].Init(); } else if (i > 0) { perkItemList.Add(UIPerkItem.Clone(perkItemList[0].rootObj, "PerkButton" + (i + 1))); } perkItemList[i].imgIcon.sprite = perkList[i].icon; perkItemList[i].perkID = perkList[i].ID; perkItemList[i].selectHighlight.SetActive(i == 0); perkItemList[i].SetCallback(null, null, this.OnPerkItem, null); } UpdateContentRectSize(); } else { for (int i = 0; i < perkItemList.Count; i++) { perkItemList[i].Init(); perkItemList[i].selectHighlight.SetActive(i == 0); perkItemList[i].SetCallback(null, null, this.OnPerkItem, null); } } List <Rsc> rscList = ResourceManager.GetResourceList(); for (int i = 0; i < rscList.Count; i++) { if (i == 0) { rscItemList[0].Init(); } else { rscItemList.Add(UIObject.Clone(rscItemList[0].rootObj, "Rsc" + (i + 1))); } rscItemList[i].imgRoot.sprite = rscList[i].icon; rscItemList[i].label.text = ""; } rscRootObj = rscItemList[0].rectT.parent.gameObject; butPurchase.Init(); UpdatePerkItemList(); UpdateDisplay(); //thisObj.SetActive(false); rectT.localPosition = new Vector3(0, 99999, 0); }