WaiXie_QuestionSystem/Assets/Script/Editor/BuildAsset.cs

32 lines
971 B
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using UnityEngine;
using UnityEditor;
namespace ZXL.Excel
{
/// <summary>
/// 利用ScriptableObject创建资源文件
/// </summary>
public class BuildAsset : Editor
{
/// <summary>
/// 读取Excel并把Excel的内容写入成asset资源以便后面取数据的时候不用重复读取表格
/// </summary>
/// <param name="name">文件名字</param>
[MenuItem("BuildAsset/Build Scriptable Asset")]
public static void ExcuteBuild(string name, string sheetName)
{
BookHolder holder = ScriptableObject.CreateInstance<BookHolder>();
// //查询excel表中数据赋值给asset文件
// holder.menus = ReadExcel.SelectMenuTable(name, sheetName);
//
// string path = "Assets/Resources/Excel/" + name + ".asset";
//
// AssetDatabase.CreateAsset(holder, path);
AssetDatabase.Refresh();
Debug.Log("BuildAsset Success!");
}
}
}