49 lines
1019 B
C#
49 lines
1019 B
C#
|
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<ItemDataAsset>();
|
||
|
AssetDatabase.CreateAsset(exampleAsset, "Assets/Resources/ItemDataAsset.asset");
|
||
|
AssetDatabase.Refresh();
|
||
|
}
|
||
|
#endif
|
||
|
public List<ItemResourcesData> Datas;
|
||
|
public List<SlotCrafting> 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<ItemData> craftID;
|
||
|
}
|
||
|
|
||
|
[Serializable]
|
||
|
public class NPCBuyData
|
||
|
{
|
||
|
public int buyID;
|
||
|
}
|