using UnityEngine; using UnityEngine.UI; using TMPro; public class BuildingUI : MonoBehaviour { [Header("Настройки")] public ResourceCollector building; public TMP_Text stokText; public Slider progressBar; void Start() { if (building == null) { Debug.LogError("Ошибка BuildingUI: не назначено здание (Building)!"); enabled = false; return; } UpdateUI(); } void Update() { UpdateUI(); } void UpdateUI() { if (stokText != null) { stokText.text = $"{building.GetCurrentStock():F1} / {building.GetMaxCapacity()}"; } if (progressBar != null) { float fill = building.GetCurrentStock() / building.GetMaxCapacity(); progressBar.value = Mathf.Clamp01(fill); } } }