Files
XRLib/Assets/Scripts/UVC/UI/Window/ComponentListTabWindow.cs

113 lines
3.3 KiB
C#
Raw Normal View History

2025-09-26 12:01:35 +09:00
#nullable enable
using Cysharp.Threading.Tasks;
2025-12-08 21:06:05 +09:00
using System;
using System.Collections.Generic;
2025-09-26 12:01:35 +09:00
using UnityEngine;
2025-12-08 21:06:05 +09:00
using UVC.UI.List.ComponentList;
2025-09-26 12:01:35 +09:00
using UVC.UI.Tab;
2025-12-08 21:06:05 +09:00
namespace UVC.UI.Window
2025-09-26 12:01:35 +09:00
{
2025-12-08 21:06:05 +09:00
public class ComponentListTabWindow : MonoBehaviour, ITabContent, IDisposable
2025-09-26 12:01:35 +09:00
{
[SerializeField]
private TabController? tabController;
2025-12-08 21:06:05 +09:00
private SortedDictionary<string, List<ComponentListItemData>> data = new SortedDictionary<string, List<ComponentListItemData>>();
private bool _isDisposed = false;
2025-09-26 12:01:35 +09:00
protected void Awake()
{
if (tabController == null)
{
2025-09-26 18:08:07 +09:00
Debug.LogError("TabContentTabComponentList: TabController가 할당되지 않았습니다.");
2025-09-26 12:01:35 +09:00
return;
}
}
2025-12-08 21:06:05 +09:00
/// <summary>
/// 탭 콘텐츠에 데이터를 전달합니다.
/// </summary>
/// <param name="objectsData"></param>
public void SetupData(SortedDictionary<string, List<ComponentListItemData>> objectsData)
2025-09-26 12:01:35 +09:00
{
2025-12-08 21:06:05 +09:00
data = objectsData;
2025-09-26 12:01:35 +09:00
// 1. TabConfig 설정
2025-12-08 21:06:05 +09:00
tabController?.AddTabConfig("ALL", "ALL", "Prefabs/UI/List/ComponentList", "", objectsData, true);
foreach (var info in objectsData)
2025-09-26 12:01:35 +09:00
{
//info.Key 카테고리 이름
2025-12-08 21:06:05 +09:00
tabController?.AddTabConfig(info.Key, info.Key, "Prefabs/UI/List/ComponentList", "", info.Value, true);
2025-09-26 12:01:35 +09:00
}
// 2. 컨트롤러 초기화
tabController?.Initialize();
2025-12-08 21:06:05 +09:00
2025-09-26 12:01:35 +09:00
if (tabController != null)
{
2025-12-08 21:06:05 +09:00
tabController.OnTabChanged += OnTabChanged;
2025-09-26 12:01:35 +09:00
}
}
2025-12-08 21:06:05 +09:00
private void OnTabChanged(int index)
{
Debug.Log($"탭이 변경되었습니다: {index}");
}
2025-09-26 12:01:35 +09:00
/// <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;
}
2025-12-08 21:06:05 +09:00
/// <summary>
/// 메모리 정리를 수행합니다.
/// </summary>
public void Dispose()
{
if (_isDisposed)
return;
// 이벤트 핸들러 해제
if (tabController != null)
{
tabController.OnTabChanged -= OnTabChanged;
}
// 데이터 정리
data.Clear();
_isDisposed = true;
}
private void OnDestroy()
{
Dispose();
}
2025-09-26 12:01:35 +09:00
}
}