Files
XRLib/Assets/Scripts/FactorySample/Tab/TabContentHierarchy.cs
2025-12-08 21:06:05 +09:00

102 lines
3.1 KiB
C#

#nullable enable
using Cysharp.Threading.Tasks;
using UnityEngine;
using UVC.UI.List.Tree;
using UVC.UI.Tab;
using UVC.UI.Window;
namespace FactorySample.Tab
{
public class TabContentHierarchy : MonoBehaviour, ITabContent
{
[SerializeField]
private HierarchyWindow? hierarchyWindow;
protected void Awake()
{
if (hierarchyWindow == null)
{
hierarchyWindow = GetComponentInChildren<HierarchyWindow>();
}
if (hierarchyWindow == null)
{
Debug.LogError("InfiniteScroll component is not assigned or found in Children.");
return;
}
}
public void Start()
{
SetupData();
}
public void SetupData()
{
if (hierarchyWindow == null) return;
for (int i = 0; i < 10; i++)
{
TreeListItemData itemData = new TreeListItemData("Item " + i);
int len = 5;// i < 5 ? 0 : 2;// Random.Range(1, 5);
Debug.Log("len: " + len);
for (int j = 0; j < len; j++)
{
itemData.AddChild(new TreeListItemData("Item " + i + "." + j));
int childLen = 3;// Random.Range(0, 3);
for (int k = 0; k < childLen; k++)
{
itemData.Children[j].AddChild(new TreeListItemData("Item " + i + "." + j + "." + k));
for (int l = 0; l < 2; l++)
{
itemData.Children[j].Children[k].AddChild(new TreeListItemData("Item " + i + "." + j + "." + k + "." + l));
}
}
}
hierarchyWindow.AddItem(itemData);
}
}
/// <summary>
/// 새로고침 버튼 클릭 시 호출됩니다.
/// 리스트의 모든 데이터를 지우고 SetupData를 다시 호출하여 목록을 갱신합니다.
/// </summary>
public void Refresh()
{
}
/// <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;
}
}
}