113 lines
3.3 KiB
C#
113 lines
3.3 KiB
C#
#nullable enable
|
|
using Cysharp.Threading.Tasks;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UVC.UI.List.ComponentList;
|
|
using UVC.UI.Tab;
|
|
|
|
namespace UVC.UI.Window
|
|
{
|
|
public class ComponentListTabWindow : MonoBehaviour, ITabContent, IDisposable
|
|
{
|
|
[SerializeField]
|
|
private TabController? tabController;
|
|
|
|
private SortedDictionary<string, List<ComponentListItemData>> data = new SortedDictionary<string, List<ComponentListItemData>>();
|
|
|
|
private bool _isDisposed = false;
|
|
|
|
protected void Awake()
|
|
{
|
|
if (tabController == null)
|
|
{
|
|
Debug.LogError("TabContentTabComponentList: TabController가 할당되지 않았습니다.");
|
|
return;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 탭 콘텐츠에 데이터를 전달합니다.
|
|
/// </summary>
|
|
/// <param name="objectsData"></param>
|
|
public void SetupData(SortedDictionary<string, List<ComponentListItemData>> objectsData)
|
|
{
|
|
data = objectsData;
|
|
// 1. TabConfig 설정
|
|
tabController?.AddTabConfig("ALL", "ALL", "Prefabs/UI/List/ComponentList", "", objectsData, true);
|
|
foreach (var info in objectsData)
|
|
{
|
|
//info.Key 카테고리 이름
|
|
tabController?.AddTabConfig(info.Key, info.Key, "Prefabs/UI/List/ComponentList", "", info.Value, true);
|
|
}
|
|
|
|
// 2. 컨트롤러 초기화
|
|
tabController?.Initialize();
|
|
|
|
|
|
if (tabController != null)
|
|
{
|
|
tabController.OnTabChanged += OnTabChanged;
|
|
}
|
|
}
|
|
|
|
private void OnTabChanged(int index)
|
|
{
|
|
Debug.Log($"탭이 변경되었습니다: {index}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 탭 콘텐츠에 데이터를 전달합니다.
|
|
/// </summary>
|
|
/// <param name="data">전달할 데이터 객체</param>
|
|
public void SetContentData(object? data)
|
|
{
|
|
Debug.Log("TabContentTabComponentList: SetContentData called");
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 탭 전환 시 데이터가 있는 경우 전달 되는 데이터. SetContentData 이후 호출 됨
|
|
/// </summary>
|
|
/// <param name="data">전달할 데이터 객체</param>
|
|
public void UpdateContentData(object? data)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 닫힐 때 실행되는 로직을 처리합니다.
|
|
/// </summary>
|
|
/// <returns>비동기 닫기 작업을 나타내는 <see cref="UniTask"/>입니다.</returns>
|
|
public UniTask OnCloseAsync()
|
|
{
|
|
Debug.Log("TabContentTabComponentList: OnClose called");
|
|
return UniTask.CompletedTask;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 메모리 정리를 수행합니다.
|
|
/// </summary>
|
|
public void Dispose()
|
|
{
|
|
if (_isDisposed)
|
|
return;
|
|
|
|
// 이벤트 핸들러 해제
|
|
if (tabController != null)
|
|
{
|
|
tabController.OnTabChanged -= OnTabChanged;
|
|
}
|
|
|
|
// 데이터 정리
|
|
data.Clear();
|
|
|
|
_isDisposed = true;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Dispose();
|
|
}
|
|
}
|
|
}
|