123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- using UnityEditor;
- namespace KairoEngine.Inventory
- {
- public class ItemLibrary : MonoBehaviour
- {
-
- public string itemsDataPath = "/Assets/Data/MaxRaider/Items";
-
- public static List<ItemBase> itemList;
- public List<ItemBase> availableItems;
- void Awake()
- {
- ItemLibrary.itemList = availableItems;
- }
- public static ItemBase GetItemByName(string title)
- {
- for (int i = 0; i < itemList.Count; i++)
- {
- if(itemList[i].title == title)
- {
- return itemList[i];
- }
- }
- return null;
- }
- // [HorizontalGroup("Import Items from Path")]
- // [Button]
- // private void ImportLibrary()
- // {
- // Debug.Log("Importing items from " + itemsDataPath);
- // itemList = new List<ItemBase>();
- // Object[] objectArray = AssetDatabase.LoadAllAssetsAtPath(itemsDataPath);
- // Debug.Log("Found " + objectArray.Length + " files.");
- // foreach (var obj in objectArray)
- // {
- // Debug.Log(obj);
- // itemList.Add((ItemBase)obj);
- // }
- // Debug.Log("Imported " + itemList.Count + " items to the library.");
- // }
- }
- }
|