void GenerateBuildingButtons() { DestroyBuildingButtons(); int start = CurrentPage == 1 ? 0 : (6 * (CurrentPage - 1)); int end = (start + 6) <= Buildings.Count ? (start + 6) : Buildings.Count; for (int i = start; i < end; i++) { if (i >= Buildings.Count) { break; } GameObject go = Instantiate(buildingBtnPrefab, buildingMenuCanvas); BuildingButton buildingButton = go.GetComponentInChildren <BuildingButton>(); GameObject model = Instantiate(Buildings[i].Model, buildingButton.modelParent.transform); model.transform.localPosition = Vector3.zero; buildingButton.ScaleModel(iconSize); buildingButton.index = i; buildingButton.costText.text = "£" + Buildings[i].Cost.ToString(); buildingButton.nameText.text = Buildings[i].Name; go.SetActive(true); buildingButton.GetComponent <CompoundButton>().OnButtonClicked += BuildingPressed; } UIManager.Instance.BuildingsGenerated(Buildings.Count); }
public void ActivateButton(BuildingButton button) { foreach (BuildingButton BB in CurrentTab.BuildingButtons) { BB.GetComponent <Image>().color = FrameDefaultColor; } button.GetComponent <Image>().color = FrameActiveColor; }