public void ReplaceCat() { var catList = playerDataManager.GetComponent <DataManager>().getCurCats(); var curCatSlot = GameObject.FindGameObjectWithTag("CurrentCat"); bool discardFlag = curCatSlot.GetComponent <ReplaceSlots>().exitReplace; if (discardFlag) { curCatSlot.GetComponent <ReplaceSlots>().exitReplace = false; OnReplaceComplete(); } int index = 0; foreach (Transform child in ReplacePanel.transform) { ReplaceSlots slot = child.GetComponent <ReplaceSlots>(); if (slot.toBeReplaced == true) { slot.toBeReplaced = false; OnReplaceComplete(); } index++; } }
public void updatePanelSlots() { playerDataManager = GameObject.FindGameObjectWithTag("DataManager"); var catList = playerDataManager.GetComponent <DataManager>().getCurCats(); int index = 0; foreach (Transform child in ReplacePanel.transform) { ReplaceSlots slot = child.GetComponent <ReplaceSlots>(); if (index < catList.Count) { var assetPath = "Prefabs/Inventory/" + catList[index]; slot.item = Resources.Load <Pokemon>(assetPath); } else { slot.item = (Pokemon)Resources.Load("Prefabs/Inventory/No Cat");; } slot.updateSlot(); index++; } }