using System.Collections.Generic; using Managers; using UnityEngine; // InventoryUI.cs public class EquipmentUIController : MonoBehaviour { public Transform itemParent; private readonly Dictionary _slots = new(); private void Start() { Debug.Log("EquipmentUI Start"); if (itemParent == null) { Debug.LogWarning("ItemParent is null! Can not attach"); return; } // Delete existing children if any. foreach (Transform child in itemParent) Destroy(child.gameObject); if (EquipmentManager.Instance.Slots.Count == 0) EquipmentManager.Instance.Initialize(PlayerManager.Instance.playerData); var slotPrefab = PrefabManager.Instance.GetSlotPrefab(); // var itemPrefab = prefabManager.GetItemPrefab(); foreach (var slot in EquipmentManager.Instance.Slots) { // Draw slots to screen var slotDisplay = Instantiate(slotPrefab, itemParent); slotDisplay.transform.localScale = new Vector3((float)0.5, (float)0.5, (float)0.5); var i = slot.Key; var slotComponent = slotDisplay.GetComponent(); // Add prefab to slot slotComponent.SetSlotDetails(slot.Value); _slots.Add(i, slotDisplay); } Debug.Log("Finished adding items to toolbar slots"); } public void ListChildren(GameObject parent) { foreach (Transform child in parent.transform) Debug.Log("Child: " + child.name); } public void UpdateUI() { // Get values from inventory and redraw the inventory slots based on that. } }