2026-09-03 00:49:31 +03:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2026-09-05 14:10:05 +03:00
|
|
|
using TMPro;
|
2026-09-03 00:49:31 +03:00
|
|
|
|
|
|
|
|
public class BuildingUI : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[Header("Настройки")]
|
2026-09-05 16:39:40 +03:00
|
|
|
public ResourceCollector building;
|
|
|
|
|
public TMP_Text stokText;
|
|
|
|
|
public Slider progressBar;
|
2026-09-03 00:49:31 +03:00
|
|
|
|
2026-09-05 16:39:40 +03:00
|
|
|
void Start()
|
2026-09-03 00:49:31 +03:00
|
|
|
{
|
|
|
|
|
if (building == null)
|
|
|
|
|
{
|
2026-09-05 16:39:40 +03:00
|
|
|
Debug.LogError("Ошибка BuildingUI: не назначено здание (Building)!");
|
2026-09-03 00:49:31 +03:00
|
|
|
enabled = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
UpdateUI();
|
|
|
|
|
}
|
2026-09-05 16:39:40 +03:00
|
|
|
|
2026-09-03 00:49:31 +03:00
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
UpdateUI();
|
|
|
|
|
}
|
2026-09-05 16:39:40 +03:00
|
|
|
|
2026-09-03 00:49:31 +03:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-09-05 16:39:40 +03:00
|
|
|
}
|