using UnityEngine; using UnityEngine.UI; using TMPro; public class FurniturePaletteUI : MonoBehaviour { [Header("UI Элементы: Палитра (Scroll View)")] public GameObject palettePanel; public Transform colorsContainer; public GameObject colorBtnTemplate; [Header("UI Элементы: Вкладки деталей")] public GameObject tabsPanel; public Transform tabsContainer; public GameObject tabBtnTemplate; private FurnitureObject _currentFurniture; private FurnitureVisuals _currentVisuals; private int _selectedSlotIndex = 0; public void ShowColors(FurnitureObject furniture) { if (furniture == null || furniture.runtimeItemData == null) return; _currentVisuals = furniture.GetComponent(); if (_currentVisuals == null || furniture.runtimeItemData.configurableSlots.Count == 0) { HideColors(); return; } _currentFurniture = furniture; _selectedSlotIndex = 0; GenerateTabs(); ShowColorsForSlot(_selectedSlotIndex); palettePanel.SetActive(true); tabsPanel.SetActive(furniture.runtimeItemData.configurableSlots.Count > 1); } private void GenerateTabs() { foreach (Transform child in tabsContainer) Destroy(child.gameObject); for (int i = 0; i < _currentFurniture.runtimeItemData.configurableSlots.Count; i++) { int slotIndex = i; string slotName = _currentFurniture.runtimeItemData.configurableSlots[i].slotName; GameObject tabObj = Instantiate(tabBtnTemplate, tabsContainer, false); tabObj.transform.localScale = Vector3.one; TextMeshProUGUI tabText = tabObj.GetComponentInChildren(); if (tabText != null) tabText.text = slotName; Button btn = tabObj.GetComponent