WXGame/box1/Assets/Script/AssetData.cs
2024-11-26 15:44:50 +08:00

38 lines
857 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
public class AssetData : ScriptableObject
{
#if UNITY_EDITOR
[MenuItem("工具/创建资源数据")]
static void CreateExampleAssetInstance()
{
var exampleAsset = CreateInstance<AssetData>();
AssetDatabase.CreateAsset(exampleAsset, "Assets/Resources/AssetData.asset");
AssetDatabase.Refresh();
}
#endif
public List<ImageAsset> buildData;
public Dictionary<string, Sprite> buildDic = new Dictionary<string, Sprite>();
public void InitData()
{
foreach (var dAsset in buildData)
{
buildDic.Add(dAsset.icon.name,dAsset.icon);
}
}
}
[Serializable]
public class ImageAsset
{
public string key;
public Sprite icon;
}