44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SkillWindowUI : MonoBehaviour
|
|
{
|
|
[SerializeField] private Transform _listContentRoot;
|
|
[SerializeField] private GameObject _skillEntryPrefab;
|
|
|
|
private readonly List<SkillEntry> _entries = new List<SkillEntry>();
|
|
|
|
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<SkillModule>(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<SkillEntry>();
|
|
if (entry != null)
|
|
{
|
|
entry.SetData(skills[i]);
|
|
_entries.Add(entry);
|
|
}
|
|
}
|
|
}
|
|
}
|