인벤토리 코드 첫커밋
This commit is contained in:
parent
3c280656b4
commit
fbc9c88d59
46
Assets/Scirpts/Inventory.cs
Normal file
46
Assets/Scirpts/Inventory.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DDD
|
||||||
|
{
|
||||||
|
public class Inventory : MonoBehaviour
|
||||||
|
{
|
||||||
|
Dictionary<string, Item> inventory;
|
||||||
|
private List<RectTransform> unusedItems;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
var task= GoogleSheetManager.LoadSo<ItemSo>();
|
||||||
|
var items = task.Result;
|
||||||
|
|
||||||
|
unusedItems = new List<RectTransform>();
|
||||||
|
|
||||||
|
// 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()
|
||||||
|
{
|
||||||
|
RectTransform inventoryRoot;
|
||||||
|
RectTransform itemPrefab;
|
||||||
|
|
||||||
|
var counts = inventoryRoot.childCount;
|
||||||
|
for (int i = 0; i < counts; ++i)
|
||||||
|
{
|
||||||
|
var child = inventoryRoot.GetChild(0);
|
||||||
|
unusedItems.Add(child as RectTransform);
|
||||||
|
child.SetParent(null);
|
||||||
|
child.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in inventory)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
Assets/Scirpts/Inventory.cs.meta
Normal file
2
Assets/Scirpts/Inventory.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6c667d81563204249aea17e2052c7e50
|
Loading…
Reference in New Issue
Block a user