85 lines
2.3 KiB
C#
85 lines
2.3 KiB
C#
using System;
|
||
using System.IO;
|
||
using UnityEditor;
|
||
using UnityEngine;
|
||
using XLua;
|
||
using Debug = UnityEngine.Debug;
|
||
|
||
namespace BFEditor
|
||
{
|
||
public class ExportExcelWindow : EditorWindow
|
||
{
|
||
private string designExcelPath = "";
|
||
private bool designSuccFlag = false;
|
||
private bool skillSpecialSuccFlag = false;
|
||
private bool isDev = false;
|
||
|
||
public ExportExcelWindow()
|
||
{
|
||
this.titleContent = new GUIContent("导表工具");
|
||
}
|
||
|
||
void Awake()
|
||
{
|
||
var luaPath = Path.Combine(Application.dataPath, "Developer/lua/main.lua").Replace("\\", "/");
|
||
isDev = File.Exists(luaPath);
|
||
}
|
||
|
||
private void OnEnable()
|
||
{
|
||
designExcelPath = ExportExcelTools.GetDesignExcelPath();
|
||
}
|
||
|
||
private void OnGUI()
|
||
{
|
||
#region 设置Excel路径
|
||
GUILayout.Space(18);
|
||
GUILayout.BeginHorizontal();
|
||
GUILayout.Label("选择excel路径");
|
||
GUILayout.TextField(designExcelPath, GUILayout.Width(300));
|
||
if (GUILayout.Button("选择", GUILayout.Width(80)))
|
||
{
|
||
string openPath = EditorUtility.OpenFolderPanel("select excel path", designExcelPath, "");
|
||
if (openPath.CompareTo("") != 0){
|
||
designExcelPath = openPath;
|
||
}
|
||
}
|
||
GUILayout.EndHorizontal();
|
||
GUILayout.Space(10);
|
||
#endregion
|
||
|
||
#region 导出lua
|
||
GUILayout.BeginHorizontal();
|
||
GUILayout.Space(150);
|
||
if (GUILayout.Button("一键导表", GUILayout.Width(200), GUILayout.Height(40)))
|
||
{
|
||
bool succ = OnClickExport();
|
||
if (succ)
|
||
{
|
||
Close();
|
||
EditorUtility.DisplayDialog("成功", "导出成功!", "ok");
|
||
}
|
||
else
|
||
{
|
||
Close();
|
||
EditorUtility.DisplayDialog("失败", "导出失败!", "ok");
|
||
}
|
||
}
|
||
GUILayout.EndHorizontal();
|
||
GUILayout.Space(30);
|
||
#endregion
|
||
}
|
||
|
||
private bool OnClickExport()
|
||
{
|
||
if (string.IsNullOrEmpty(designExcelPath) || !Directory.Exists(designExcelPath))
|
||
{
|
||
EditorUtility.DisplayDialog("错误", "excel路径不存在,请先设置正确路径", "ok");
|
||
return false;
|
||
}
|
||
ExportExcelTools.SetDesignExcelPath(designExcelPath);
|
||
return ExportExcelTools.FastExportExcelToLua(isDev, designExcelPath);
|
||
}
|
||
}
|
||
}
|