using UnityEngine;
using UnityEngine.UI;
using TMPro;
///
/// Создаёт UI инвентаря программно с использованием TextMeshPro
///
public class InventoryUIBuilder : MonoBehaviour
{
[Header("Settings")]
public int hotbarSlots = 9;
public int inventoryRows = 4;
public int inventoryCols = 9;
[Header("Visual Settings")]
public float slotSize = 50f;
public float slotSpacing = 4f;
public float inventoryPadding = 10f;
public float hotbarPadding = 10f;
[Header("Colors")]
[SerializeField] private Color inventoryPanelColor = new Color(0.15f, 0.15f, 0.15f, 0.95f);
[SerializeField] private Color hotbarPanelColor = new Color(0.1f, 0.1f, 0.1f, 0.9f);
[SerializeField] private Color slotEmptyColor = new Color(0.25f, 0.25f, 0.25f, 0.8f);
[SerializeField] private Color slotFilledColor = new Color(0.35f, 0.35f, 0.35f, 0.95f);
[Header("Container References")]
public RectTransform inventoryPanelRect;
public RectTransform hotbarPanelRect;
public Canvas inventoryCanvas;
void Start()
{
// Проверяем, не запущен ли уже BuildInventoryUI
if (InventoryManager.Instance != null &&
InventoryManager.Instance.slots != null &&
InventoryManager.Instance.slots.Length > 0)
{
Debug.Log("[InventoryUIBuilder] UI already built, skipping");
return;
}
BuildInventoryUI();
}
public void BuildInventoryUI()
{
// Создаём или получаем Canvas
var canvas = GetComponent