ItemLibrary.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. using UnityEditor;
  6. namespace KairoEngine.Inventory
  7. {
  8. public class ItemLibrary : MonoBehaviour
  9. {
  10. public string itemsDataPath = "/Assets/Data/MaxRaider/Items";
  11. public static List<ItemBase> itemList;
  12. public List<ItemBase> availableItems;
  13. void Awake()
  14. {
  15. ItemLibrary.itemList = availableItems;
  16. }
  17. public static ItemBase GetItemByName(string title)
  18. {
  19. for (int i = 0; i < itemList.Count; i++)
  20. {
  21. if(itemList[i].title == title)
  22. {
  23. return itemList[i];
  24. }
  25. }
  26. return null;
  27. }
  28. // [HorizontalGroup("Import Items from Path")]
  29. // [Button]
  30. // private void ImportLibrary()
  31. // {
  32. // Debug.Log("Importing items from " + itemsDataPath);
  33. // itemList = new List<ItemBase>();
  34. // Object[] objectArray = AssetDatabase.LoadAllAssetsAtPath(itemsDataPath);
  35. // Debug.Log("Found " + objectArray.Length + " files.");
  36. // foreach (var obj in objectArray)
  37. // {
  38. // Debug.Log(obj);
  39. // itemList.Add((ItemBase)obj);
  40. // }
  41. // Debug.Log("Imported " + itemList.Count + " items to the library.");
  42. // }
  43. }
  44. }