private void PopulateButtonValues(GameObject button, BaseBuilding buildingData) { button.GetComponent <Button>().onClick.AddListener(() => { GameObject fillMeter = button.GetComponent <ButtonComponents>().FillMeter; Image fillMeterImage = fillMeter.GetComponent <Image>(); if (fillMeterImage.type != Image.Type.Filled) { Debug.LogError("Fill meter image type is invalid"); return; } upgradeHandler.UpgradeBuildingOnClick(buildingData); StartCoroutine(FillCooldownMeter(button, fillMeterImage, buildingData.TimeOfProduction)); }); Text buttonLabel = button.GetComponentInChildren <Text>(); buttonLabel.text = buildingData.Name; TextMeshProUGUI costText = button.GetComponent <ButtonComponents>().UpgradeCost.GetComponentInChildren <TextMeshProUGUI>(); costText.SetText(buildingData.Price.ToString()); // Last thing to do is to disable button if it's not unlocked yet if (!buildingData.IsUnlocked) { button.GetComponent <UIButton>().DisableButton(); } }