loudixvmuniu/Assets/Third/Excel/ExcelTools.cs
“CongG” 9c45e1f3d0 重新设置摄像机位置工具
优化整理同期发情相关动画
2025-01-02 19:36:17 +08:00

39 lines
1.2 KiB
C#

using System.IO;
using UnityEngine;
using System.Text;
namespace CG.UTility
{
public static class ExcelTools
{
#if UNITY_EDITOR
/// <summary>
/// 加载Excel
/// </summary>
[UnityEditor.MenuItem("Tools/ExcelTools", false, 4)]
private static void LoadExcel()
{
string[] excelList = Directory.GetFiles(Application.streamingAssetsPath + ConstCtrl.EXCEL_PATH, "*.xlsx");
for (int i = 0; i < excelList.Length; i++)
{
Convert(excelList[i]);
}
}
#endif
/// <summary>
/// 转换Excel文件
/// </summary>
private static void Convert(string excelFile)
{
//构造Excel工具类
ExcelUtility excel = new ExcelUtility(excelFile);
excel.ConvertToJson(Application.streamingAssetsPath + ConstCtrl.JSON_PATH+ Path.GetFileNameWithoutExtension(excelFile)+".txt", new UTF8Encoding(false));
excel.ConvertToCSharp(Application.streamingAssetsPath + ConstCtrl.CSHARP_PATH + Path.GetFileNameWithoutExtension(excelFile) + ".cs", new UTF8Encoding(false));
#if UNITY_EDITOR
//刷新本地资源
UnityEditor.AssetDatabase.Refresh();
#endif
}
}
}