public void UpdateNewCompanyCostText() { int new_office_space; if (!int.TryParse(FirstOfficeSpaceInput.text, out new_office_space)) { new_office_space = 0; } new_office_space = Mathf.Clamp(Math.Abs(new_office_space), Office.MIN_OFFICE_SPACE, Office.MAX_OFFICE_SPACE); FirstOfficeSpaceInput.text = new_office_space.ToString(); int total_cost = Company.BASE_COMPANY_COST + (Office.COST_PER_SPACE * new_office_space); NewCompanyCostText.text = string.Format("New Company Cost: ${0}", total_cost); CreateCompanyButton.onClick.RemoveListener(CreateCompany); if (total_cost <= Character.MyCharacter.Funds && total_cost != 0) { CreateCompanyButton.onClick.AddListener(CreateCompany); } CreateCompanyButton.colors = ColorBlocks.GetColorBlock(total_cost <= Character.MyCharacter.Funds ? Color.green : Color.red); }
public void SetupActionButton(Color buttonColor, string buttonText, UnityAction buttonAction) { ActionButton.colors = ColorBlocks.GetColorBlock(buttonColor); ActionButton.GetComponentInChildren <Text>().text = buttonText; ActionButton.onClick.AddListener(buttonAction); }