using System; using System.Collections; using System.Collections.Generic; using System.Linq; #if UNITY_EDITOR using UnityEditor; #endif using UnityEngine; public class ItemDataAsset : ScriptableObject { #if UNITY_EDITOR [MenuItem("工具/创建资源数据")] static void CreateExampleAssetInstance() { var exampleAsset = CreateInstance(); AssetDatabase.CreateAsset(exampleAsset, "Assets/Resources/ItemDataAsset.asset"); AssetDatabase.Refresh(); } #endif public List Datas; public List crafting; public Sprite IconSprite(int id) { var data = Datas.FirstOrDefault(data => data.id == id); return data?.icon; } } [Serializable] public class ItemResourcesData { public int id; public Sprite icon; } [Serializable] public class SlotCrafting { public int id; public List craftID; } [Serializable] public class NPCBuyData { public int buyID; }