private void SetButton(Button button, BuildingPrefab prefab) { StatBar statBar = button.gameObject.transform.parent.GetComponentInChildren <StatBar>(); if (statBar == null) { return; } for (int i = 0; i < prefab.Happiness; i++) { statBar.Happiness[i].gameObject.SetActive(true); } for (int i = 0; i < prefab.EnviromentValue; i++) { statBar.Enviroment[i].gameObject.SetActive(true); } float onePercent = _highestPrice / 100; int moneyValue = prefab.MyBuilding.BuildPrice / (int)onePercent; int finalValue = moneyValue / 10; for (int i = 0; i < finalValue; i++) { statBar.Money[i].gameObject.SetActive(true); } }
private void Awake() { _statBar = GetComponent <StatBar>(); }