Files
EnglewoodLAB/Assets/Scripts/Factory/Tab/TabContentLibraryGrid.cs

107 lines
2.9 KiB
C#

#nullable enable
using Cysharp.Threading.Tasks;
using System.Collections.Generic;
using UnityEngine;
using UVC.UI.List;
using UVC.UI.Tab;
namespace Factory.Tab
{
public class TabContentLibraryGrid : MonoBehaviour, ITabContent
{
[SerializeField]
private PrefabGrid? prefabGrid;
protected void Awake()
{
if (prefabGrid == null)
{
prefabGrid = GetComponentInChildren<PrefabGrid>();
}
if (prefabGrid == null)
{
Debug.LogError("InfiniteScroll component is not assigned or found in Children.");
return;
}
}
public void Start()
{
SetupData();
}
public void SetupData()
{
List<string> imagePath = new List<string>()
{
"Simulator/Images/lib_forklift_400x300",
"Simulator/Images/lib_pallet_400x300",
"Simulator/Images/lib_worker_400x300",
};
List<string> prefabPath = new List<string>()
{
"Prefabs/Forklift",
"Prefabs/PalletEmpty",
"Prefabs/Male Young Guy",
};
List<PrefabGridItemData> list = new List<PrefabGridItemData>();
for (int i = 0; i < 20; i++)
{
list.Add(new PrefabGridItemData()
{
Id = i.ToString(),
ItemName = $"Item {i}",
ImagePrefabPath = imagePath[i % 3],
ObjectPrefabPath = prefabPath[i % 3]
});
}
prefabGrid?.SetupData(list);
}
/// <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;
}
}
}