| | |
| | | using System;
|
| | | using System.CodeDom;
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Security.Cryptography;
|
| | | using System.Text;
|
| | | using System.Windows.Forms;
|
| | | using UnityEditor;
|
| | |
| | | public class TableTool : EditorWindow
|
| | | {
|
| | |
|
| | | public static string configOutPutPath = UnityEngine.Application.dataPath + "/StreamingAssets/Config";
|
| | | public static string configOutPutPath;
|
| | | static bool isIL = false; // 导出表代码是否IL使用
|
| | |
|
| | | [UnityEditor.MenuItem("策划工具/导出策划表到游戏工程")]
|
| | | static void Init()
|
| | | {
|
| | | window = GetWindow(typeof(TableTool), true, "策划导表工具") as TableTool;
|
| | | configOutPutPath = UnityEngine.Application.dataPath + "/StreamingAssets/Config";
|
| | | window = GetWindow(typeof(TableTool), false, "策划导表工具") as TableTool;
|
| | | window.position = new Rect(UnityEngine.Screen.width / 2, UnityEngine.Screen.height / 2, 300, 700);
|
| | | window.Show();
|
| | | PathCache();
|
| | | //PathCache();
|
| | | }
|
| | |
|
| | | public class FileToggleInfo
|
| | |
| | | private static List<FileToggleInfo> _tableNameLst = new List<FileToggleInfo>(); //所有表名字列表
|
| | | private void OnGUI()
|
| | | {
|
| | | _tablePath = UnityEngine.Application.dataPath + "/ResourcesOut/Refdata/Config";
|
| | | GUILayout.BeginVertical();
|
| | | GUILayout.TextArea("策划配表路径:" + _tablePath);
|
| | |
|
| | |
| | | GUILayout.BeginHorizontal();
|
| | | if (GUILayout.Button("导出表"))
|
| | | {
|
| | | isIL = false;
|
| | | ReadAllTxt();
|
| | | GenAllClass();
|
| | | MessageBox.Show("导出表成功!");
|
| | |
| | | }
|
| | | GUILayout.EndHorizontal();
|
| | |
|
| | | GUILayout.EndVertical();
|
| | | // GUILayout.BeginHorizontal();
|
| | | // if (GUILayout.Button("导出IL表"))
|
| | | // {
|
| | | // isIL = true;
|
| | | // ReadAllTxt();
|
| | | // GenAllClass();
|
| | | // MessageBox.Show("导出IL表成功!");
|
| | | // AssetDatabase.Refresh();
|
| | | // isIL = false;
|
| | | // }
|
| | | // GUILayout.EndHorizontal();
|
| | |
|
| | | if (GUILayout.Button("选择路径"))
|
| | | {
|
| | | #if UNITY_EDITOR
|
| | | FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
|
| | |
|
| | | if (folderBrowserDialog.ShowDialog() == DialogResult.OK || folderBrowserDialog.ShowDialog() == DialogResult.Yes)
|
| | | {
|
| | | _tablePath = folderBrowserDialog.SelectedPath + "\\";
|
| | | PathCache(_tablePath);
|
| | | }
|
| | | // if (GUILayout.Button("选择路径"))
|
| | | // {
|
| | | //#if UNITY_EDITOR
|
| | | // FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
|
| | |
|
| | | folderBrowserDialog.Dispose();
|
| | | #endif
|
| | | // if (folderBrowserDialog.ShowDialog() == DialogResult.OK || folderBrowserDialog.ShowDialog() == DialogResult.Yes)
|
| | | // {
|
| | | // _tablePath = folderBrowserDialog.SelectedPath + "\\";
|
| | | // PathCache(_tablePath);
|
| | | // }
|
| | |
|
| | | }
|
| | | // folderBrowserDialog.Dispose();
|
| | | //#endif
|
| | |
|
| | | // }
|
| | | GUIUtility.ExitGUI();
|
| | | }
|
| | |
|
| | | private void ShowTableNames()
|
| | |
| | | continue;
|
| | | }
|
| | | FileStream fileStream = _tableNameLst[i].fileInfo.OpenRead();
|
| | | StreamReader sr = new StreamReader(fileStream, Encoding.Default);
|
| | | CreateConfigClassFile.CreateConfigClass(_tableNameLst[i].fileInfo);
|
| | | StreamReader sr = new StreamReader(fileStream, Encoding.UTF8);
|
| | | CreateConfigClassFile.CreateConfigClass(_tableNameLst[i].fileInfo, isIL);
|
| | | sr.Dispose();
|
| | | sr.Close();
|
| | | }
|
| | |
| | | /// 路径缓存
|
| | | /// </summary>
|
| | | /// <param name="setPath"></param>
|
| | | private static void PathCache(string setPath = "")
|
| | | {
|
| | | DebugEx.Log("路径缓存:" + setPath);
|
| | | string configPath = UnityEngine.Application.dataPath;
|
| | | configPath = configPath + "/ResourcesOut/Refdata/Config/PathCache/TablePath.txt";
|
| | | FileStream configPathTxt = File.Open(configPath, FileMode.Open);
|
| | | if (string.IsNullOrEmpty(setPath))
|
| | | {
|
| | | StreamReader sr = new StreamReader(configPathTxt);
|
| | | string path = sr.ReadToEnd();
|
| | | _tablePath = path;
|
| | | sr.Dispose();
|
| | | sr.Close();
|
| | | }
|
| | | else
|
| | | {
|
| | | StreamWriter sw = new StreamWriter(configPathTxt);
|
| | | sw.Write(setPath);
|
| | | sw.Dispose();
|
| | | sw.Close();
|
| | | }
|
| | | }
|
| | | //private static void PathCache(string setPath = "")
|
| | | //{
|
| | | // DebugEx.Log("路径缓存:" + setPath);
|
| | | // string configPath = UnityEngine.Application.dataPath;
|
| | | // configPath = configPath + "/ResourcesOut/Refdata/Config/PathCache/TablePath.txt";
|
| | | // FileStream configPathTxt = File.Open(configPath, FileMode.Open);
|
| | | // if (string.IsNullOrEmpty(setPath))
|
| | | // {
|
| | | // StreamReader sr = new StreamReader(configPathTxt);
|
| | | // string path = sr.ReadToEnd();
|
| | | // _tablePath = path;
|
| | | // sr.Dispose();
|
| | | // sr.Close();
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // StreamWriter sw = new StreamWriter(configPathTxt);
|
| | | // sw.Write(setPath);
|
| | | // sw.Dispose();
|
| | | // sw.Close();
|
| | | // }
|
| | | //}
|
| | | }
|
| | |
|
| | | public class Param
|