using System.Collections.Generic; using UnityEngine; public class SkillWindowUI : MonoBehaviour { [SerializeField] private Transform _listContentRoot; [SerializeField] private GameObject _skillEntryPrefab; private readonly List _entries = new List(); public void Toggle() { bool willOpen = !gameObject.activeSelf; gameObject.SetActive(willOpen); if (willOpen) Refresh(); } public void Refresh() { // 기존 엔트리 정리 foreach (Transform child in _listContentRoot) Destroy(child.gameObject); _entries.Clear(); var character = GameManager.Instance.Level.CurrentCharacter; if (character == null) return; if (!character.TryGetComponent(out var skillModule)) return; var skills = skillModule.GetEquippedSkillDatas(); for (int i = 0; i < skills.Count; i++) { if (skills[i] == null) continue; GameObject entryObj = Instantiate(_skillEntryPrefab, _listContentRoot); SkillEntry entry = entryObj.GetComponent(); if (entry != null) { entry.SetData(skills[i]); _entries.Add(entry); } } } }