folderchange
This commit is contained in:
54
Assets/Sample/Scenes/LibraryWindowSample.cs
Normal file
54
Assets/Sample/Scenes/LibraryWindowSample.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UVC.UI.List;
|
||||
using UVC.UI.Window;
|
||||
|
||||
public class LibraryWindowSample : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private LibraryWindow libraryWindow;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
List<string> imagePath = new List<string>()
|
||||
{
|
||||
"Images/lib_forklift_400x300",
|
||||
"Images/lib_pallet_400x300",
|
||||
"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],
|
||||
OnClickAction = OnClickGridItem,
|
||||
OnDropAction = OnDropGridItem
|
||||
});
|
||||
}
|
||||
|
||||
libraryWindow.SetData(list);
|
||||
}
|
||||
|
||||
private void OnClickGridItem(PrefabGridItemData data)
|
||||
{
|
||||
Debug.Log($"Clicked Item: {data.ItemName}, PrefabPath: {data.ObjectPrefabPath}");
|
||||
}
|
||||
|
||||
private void OnDropGridItem(PrefabGridItemData data)
|
||||
{
|
||||
Debug.Log($"Dropped Item: {data.ItemName}, PrefabPath: {data.ObjectPrefabPath}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user