42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
|
|
using System;
|
|||
|
|
using System.IO;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEditor;
|
|||
|
|
|
|||
|
|
namespace MMO
|
|||
|
|
{
|
|||
|
|
public class MMOTools : Editor
|
|||
|
|
{
|
|||
|
|
private class PathConfig
|
|||
|
|
{
|
|||
|
|
public static readonly string ExcelPath = Application.dataPath + "/MMOModule/Excel/";
|
|||
|
|
public static readonly string TablePath = "Assets/MMOModule/Resources/MMOTable/";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[MenuItem("MMOTool/导表")]
|
|||
|
|
public static void CreateTables()
|
|||
|
|
{
|
|||
|
|
CreateTableAsset<MMOTableTask, MMODataTask>();
|
|||
|
|
CreateTableAsset<MMOTableLevelDiamond, MMODataLevelDiamond>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private static void CreateTableAsset<T, U>() where T : MMOTableBase<T, U>
|
|||
|
|
{
|
|||
|
|
string tTableName = typeof(T).Name;
|
|||
|
|
|
|||
|
|
T tTableAsset = CreateInstance<T>();
|
|||
|
|
tTableAsset.ParseExcel(PathConfig.ExcelPath + string.Format("{0}.xlsx", tTableName));
|
|||
|
|
|
|||
|
|
if (!Directory.Exists(PathConfig.TablePath))
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(PathConfig.TablePath);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string tSavePath = string.Format("{0}{1}.asset", PathConfig.TablePath, tTableName);
|
|||
|
|
AssetDatabase.CreateAsset(tTableAsset, tSavePath);
|
|||
|
|
AssetDatabase.SaveAssets();
|
|||
|
|
|
|||
|
|
AssetDatabase.Refresh();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|