63 lines
2.1 KiB (Stored with Git LFS)
C#
63 lines
2.1 KiB (Stored with Git LFS)
C#
// using System.Collections.Generic;
|
|
// using UnityEngine;
|
|
//
|
|
// namespace DDD
|
|
// {
|
|
// public class Inventory : MonoBehaviour
|
|
// {
|
|
// public RectTransform inventoryRoot;
|
|
// public ItemUI itemPrefab;
|
|
//
|
|
// private Dictionary<string, Item> inventory;
|
|
// private Stack<ItemUI> unusedItemUIs;
|
|
// private Transform unusedRoot;
|
|
//
|
|
// private ItemUI selectedItem;
|
|
//
|
|
// private async void Start()
|
|
// {
|
|
// var task = GoogleSheetManager.LoadSo<ItemSo>();
|
|
// var items = await task;
|
|
//
|
|
// itemPrefab.transform.SetParent(null);
|
|
// itemPrefab.gameObject.SetActive(false);
|
|
//
|
|
// unusedItemUIs = new Stack<ItemUI>();
|
|
// var obj = new GameObject("UnusedRoot");
|
|
// obj.SetActive(false);
|
|
// unusedRoot = obj.transform;
|
|
//
|
|
// // TODO: 데이터에서 가져오기
|
|
// inventory = new Dictionary<string, Item>();
|
|
// inventory["0"] = items.ItemList[0];
|
|
// inventory["1"] = items.ItemList[1];
|
|
// inventory["2"] = items.ItemList[2];
|
|
// UpdateItemList();
|
|
// }
|
|
//
|
|
// public void UpdateItemList()
|
|
// {
|
|
// var counts = inventoryRoot.childCount;
|
|
// for (int i = 0; i < counts; ++i)
|
|
// {
|
|
// var child = inventoryRoot.GetChild(0);
|
|
// unusedItemUIs.Push(child.GetComponent<ItemUI>());
|
|
// child.SetParent(unusedRoot);
|
|
// }
|
|
//
|
|
// foreach (var item in inventory)
|
|
// {
|
|
// var usingPool = unusedItemUIs.TryPop(out var itemObject);
|
|
//
|
|
// if (usingPool == false)
|
|
// {
|
|
// itemObject = Instantiate(itemPrefab.gameObject).GetComponent<ItemUI>();
|
|
// }
|
|
//
|
|
// itemObject.gameObject.SetActive(true);
|
|
// itemObject.transform.SetParent(inventoryRoot);
|
|
// itemObject.SetUpItem(item.Value);
|
|
// }
|
|
// }
|
|
// }
|
|
// } |