From 4dacf3081ec1b177ee5ba2be64fe1e38e7206dd9 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Tue, 23 Feb 2021 16:20:25 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=B7=A5=E7=A8=8B=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E3=80=91=E5=B7=A5=E5=85=B7=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Resources/config.txt | 8 +- .../GameEditor/FrameTool/ConfigWindow.cs | 125 ++++++++++++++++++ .../GameEditor/FrameTool/ConfigWindow.cs.meta | 11 ++ 3 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs create mode 100644 Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs.meta diff --git a/Assets/Resources/config.txt b/Assets/Resources/config.txt index a9c5b7f715..102f62cff6 100644 --- a/Assets/Resources/config.txt +++ b/Assets/Resources/config.txt @@ -1,4 +1,10 @@ {"subChannel":"1", "buglyId":"261348dcd3", "channel":"pc", -"serverUrl":"http://60.1.1.23:8080/"} \ No newline at end of file +"serverUrl":"http://60.1.1.23:8080/", + +"func":{ +"Func_1":{"desc":"", "versionCode:"", isActive:""} +} + +} \ No newline at end of file diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs new file mode 100644 index 0000000000..f7c8d80dc4 --- /dev/null +++ b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs @@ -0,0 +1,125 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System.IO; +using System.Linq; +using GameEditor.Core; +using GameEditor.GameEditor.PlayerBuilder; +using GameLogic; +using System.Diagnostics; +using ResUpdate; +using System.Threading; + +namespace GameEditor.FrameTool { + public class ConfigWindow : EditorWindow + { + + string m_ExcelPath = EditorPrefs.GetString("m_ExcelPath"); + + // Add menu named "My Window" to the Window menu + [MenuItem("Build/Config")] + static void Init() + { + + // Get existing open window or if none, make a new one: + ConfigWindow window = (ConfigWindow)EditorWindow.GetWindow(typeof(ConfigWindow)); + window.Show(); + window.InitWindow(); + + } + + void InitWindow() + { + InitSize(); + InitGames(); + } + + /// + /// 初始化大小 + /// + void InitSize() + { + minSize = new Vector2(300, 400); + maxSize = new Vector2(300, 650); + } + + + /// + /// 初始化游戏 + /// + void InitGames() + { + } + + void OnGUI() + { + + + EditorGUILayout.BeginVertical(); + EditorGUILayout.Space(); + EditorGUILayout.LabelField("Config文件路径:"); + + EditorGUILayout.BeginHorizontal(); + m_ExcelPath = EditorGUILayout.TextField("", m_ExcelPath); + if (GUILayout.Button("加载", GUILayout.Width(60f))) + { + } + if (GUILayout.Button("打开目录", GUILayout.Width(60f))) + { + OpenDirectory(m_ExcelPath); + } + EditorGUILayout.EndHorizontal(); + + + //if (excelArr != null && excelArr.Length > 0) + //{ + // excelIndex = EditorGUILayout.Popup("选择excel文件:", excelIndex, excelArr); + //} + + } + + static string shellPath; + public static void OpenDirectory(string path) + { + if (string.IsNullOrEmpty(path)) return; + + if (!Directory.Exists(path)) + { + UnityEngine.Debug.LogError("No Directory: " + path); + return; + } + + //Application.dataPath 只能在主线程中获取 + int lastIndex = Application.dataPath.LastIndexOf("/"); + shellPath = Application.dataPath.Substring(0, lastIndex) + "/Shell/"; + + // 新开线程防止锁死 + Thread newThread = new Thread(new ParameterizedThreadStart(CmdOpenDirectory)); + newThread.Start(path); + } + private static void CmdOpenDirectory(object obj) + { + Process p = new Process(); +#if UNITY_EDITOR_WIN + p.StartInfo.FileName = "cmd.exe"; + p.StartInfo.Arguments = "/c start " + obj.ToString(); +#elif UNITY_EDITOR_OSX + p.StartInfo.FileName = "bash"; + string shPath = shellPath + "openDir.sh"; + p.StartInfo.Arguments = shPath + " " + obj.ToString(); +#endif + //UnityEngine.Debug.Log(p.StartInfo.Arguments); + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardInput = true; + p.StartInfo.RedirectStandardOutput = true; + p.StartInfo.RedirectStandardError = true; + p.StartInfo.CreateNoWindow = true; + p.Start(); + + p.WaitForExit(); + p.Close(); + } + } + +} diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs.meta b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs.meta new file mode 100644 index 0000000000..f3b8be4529 --- /dev/null +++ b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 430a2ef9ef9800c4d8bff3f5edc235e1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: