少年修仙传客户端基础资源
dabaoji
2024-08-19 e6a55f23f667ce7692d0fac11567aee2c35fe9ca
Assets/Editor/Tool/TableTool.cs
@@ -1,8 +1,6 @@
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;
@@ -11,15 +9,17 @@
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
@@ -40,6 +40,7 @@
    private static List<FileToggleInfo> _tableNameLst = new List<FileToggleInfo>(); //所有表名字列表
    private void OnGUI()
    {
        _tablePath = UnityEngine.Application.dataPath + "/ResourcesOut/Refdata/Config";
        GUILayout.BeginVertical();
        GUILayout.TextArea("策划配表路径:" + _tablePath);
@@ -65,6 +66,7 @@
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("导出表"))
        {
            isIL = false;
            ReadAllTxt();
            GenAllClass();
            MessageBox.Show("导出表成功!");
@@ -72,23 +74,35 @@
        }
        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()
@@ -261,8 +275,8 @@
                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();
        }
@@ -272,28 +286,28 @@
    /// 路径缓存
    /// </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