Просмотр исходного кода

先禁用ETProjectBrowser,还不完善

tanghai 3 лет назад
Родитель
Сommit
8044a880ef

+ 113 - 113
Unity/Assets/Scripts/Editor/AssetPostProcessor/OnGenerateCSProjectProcessor.cs

@@ -1,128 +1,128 @@
-//using System;
-//using UnityEditor;
-//using UnityEngine;
-//using System.Xml;
-//using System.IO;
-//using System.Text;
+using System;
+using UnityEditor;
+using UnityEngine;
+using System.Xml;
+using System.IO;
+using System.Text;
 
-//namespace ET
-//{
-//    public class OnGenerateCSProjectProcessor : AssetPostprocessor
-//    {
-//        public static string OnGeneratedCSProject(string path, string content)
-//        {
-            
-//            if (path.EndsWith("Unity.Hotfix.csproj"))
-//            {
-//                content =  content.Replace("<Compile Include=\"Assets\\Scripts\\Hotfix\\Empty.cs\" />", string.Empty);
-//                content =  content.Replace("<None Include=\"Assets\\Scripts\\Hotfix\\Unity.Hotfix.asmdef\" />", string.Empty);
-//            }
-            
-//            if (path.EndsWith("Unity.HotfixView.csproj"))
-//            {
-//                content =  content.Replace("<Compile Include=\"Assets\\Scripts\\HotfixView\\Empty.cs\" />", string.Empty);
-//                content =  content.Replace("<None Include=\"Assets\\Scripts\\HotfixView\\Unity.HotfixView.asmdef\" />", string.Empty);
-//            }
-            
-//            if (path.EndsWith("Unity.Model.csproj"))
-//            {
-//                content =  content.Replace("<Compile Include=\"Assets\\Scripts\\Model\\Empty.cs\" />", string.Empty);
-//                content =  content.Replace("<None Include=\"Assets\\Scripts\\Model\\Unity.Model.asmdef\" />", string.Empty);
-//            }
-            
-//            if (path.EndsWith("Unity.ModelView.csproj"))
-//            {
-//                content =  content.Replace("<Compile Include=\"Assets\\Scripts\\ModelView\\Empty.cs\" />", string.Empty);
-//                content =  content.Replace("<None Include=\"Assets\\Scripts\\ModelView\\Unity.ModelView.asmdef\" />", string.Empty);
-//            }
-            
-//            if (path.EndsWith("Unity.Hotfix.csproj"))
-//            {
-//                return GenerateCustomProject(path, content, 
-//                    @"..\Codes\Hotfix\Client\**\*.cs Client", 
-//                    @"..\Codes\Hotfix\Share\**\*.cs Share",
-//                    @"..\Codes\Hotfix\Server\**\*.cs Server"
-//                    );
-//            }
+namespace ET
+{
+    public class OnGenerateCSProjectProcessor : AssetPostprocessor
+    {
+        public static string OnGeneratedCSProject(string path, string content)
+        {
+          
+            if (path.EndsWith("Unity.Hotfix.csproj"))
+            {
+                content =  content.Replace("<Compile Include=\"Assets\\Scripts\\Hotfix\\Empty.cs\" />", string.Empty);
+                content =  content.Replace("<None Include=\"Assets\\Scripts\\Hotfix\\Unity.Hotfix.asmdef\" />", string.Empty);
+            }
+          
+            if (path.EndsWith("Unity.HotfixView.csproj"))
+            {
+                content =  content.Replace("<Compile Include=\"Assets\\Scripts\\HotfixView\\Empty.cs\" />", string.Empty);
+                content =  content.Replace("<None Include=\"Assets\\Scripts\\HotfixView\\Unity.HotfixView.asmdef\" />", string.Empty);
+            }
+          
+            if (path.EndsWith("Unity.Model.csproj"))
+            {
+                content =  content.Replace("<Compile Include=\"Assets\\Scripts\\Model\\Empty.cs\" />", string.Empty);
+                content =  content.Replace("<None Include=\"Assets\\Scripts\\Model\\Unity.Model.asmdef\" />", string.Empty);
+            }
+          
+            if (path.EndsWith("Unity.ModelView.csproj"))
+            {
+                content =  content.Replace("<Compile Include=\"Assets\\Scripts\\ModelView\\Empty.cs\" />", string.Empty);
+                content =  content.Replace("<None Include=\"Assets\\Scripts\\ModelView\\Unity.ModelView.asmdef\" />", string.Empty);
+            }
+          
+            if (path.EndsWith("Unity.Hotfix.csproj"))
+            {
+                return GenerateCustomProject(path, content, 
+                    @"..\Codes\Hotfix\Client\**\*.cs Client", 
+                    @"..\Codes\Hotfix\Share\**\*.cs Share",
+                    @"..\Codes\Hotfix\Server\**\*.cs Server"
+                    );
+            }
 
-//            if (path.EndsWith("Unity.HotfixView.csproj"))
-//            {
-//                return GenerateCustomProject(path, content, 
-//                    @"..\Codes\HotfixView\Client\**\*.cs Client", 
-//                    @"..\Codes\HotfixView\Share\**\*.cs Share"); 
-//            }
+            if (path.EndsWith("Unity.HotfixView.csproj"))
+            {
+                return GenerateCustomProject(path, content, 
+                    @"..\Codes\HotfixView\Client\**\*.cs Client", 
+                    @"..\Codes\HotfixView\Share\**\*.cs Share"); 
+            }
 
-//            if (path.EndsWith("Unity.Model.csproj"))
-//            {
-//                return GenerateCustomProject(path, content,
-//                    @"..\Codes\Model\Server\**\*.cs Server",
-//                    @"..\Codes\Model\Client\**\*.cs Client",
-//                    @"..\Codes\Model\Share\**\*.cs Share",
-//                    @"..\Codes\Generate\Server\**\*.cs Generate"
-//                    );
-//            }
+            if (path.EndsWith("Unity.Model.csproj"))
+            {
+                return GenerateCustomProject(path, content,
+                    @"..\Codes\Model\Server\**\*.cs Server",
+                    @"..\Codes\Model\Client\**\*.cs Client",
+                    @"..\Codes\Model\Share\**\*.cs Share",
+                    @"..\Codes\Generate\Server\**\*.cs Generate"
+                    );
+            }
 
-//            if (path.EndsWith("Unity.ModelView.csproj"))
-//            {
-//                return GenerateCustomProject(path, content, 
-//                    @"..\Codes\ModelView\Client\**\*.cs Client",
-//                    @"..\Codes\ModelView\Share\**\*.cs Share");
-//            }
-            
-//            return content;
-//        }
+            if (path.EndsWith("Unity.ModelView.csproj"))
+            {
+                return GenerateCustomProject(path, content, 
+                    @"..\Codes\ModelView\Client\**\*.cs Client",
+                    @"..\Codes\ModelView\Share\**\*.cs Share");
+            }
+          
+            return content;
+        }
 
-//        private static string GenerateCustomProject(string path, string content, params string[] links)
-//        {
-//            XmlDocument doc = new XmlDocument();
-//            doc.LoadXml(content);
+        private static string GenerateCustomProject(string path, string content, params string[] links)
+        {
+            XmlDocument doc = new XmlDocument();
+            doc.LoadXml(content);
 
-//            var newDoc = doc.Clone() as XmlDocument;
+            var newDoc = doc.Clone() as XmlDocument;
 
-//            var rootNode = newDoc.GetElementsByTagName("Project")[0];
+            var rootNode = newDoc.GetElementsByTagName("Project")[0];
 
-//            XmlElement itemGroup = newDoc.CreateElement("ItemGroup", newDoc.DocumentElement.NamespaceURI);
-//            foreach (var s in links)
-//            {
-//                string[] ss = s.Split(' ');
-//                string p = ss[0];
-//                string linkStr = ss[1];
-//                XmlElement compile = newDoc.CreateElement("Compile", newDoc.DocumentElement.NamespaceURI);
-//                XmlElement link = newDoc.CreateElement("Link", newDoc.DocumentElement.NamespaceURI);
-//                link.InnerText = $"{linkStr}\\%(RecursiveDir)%(FileName)%(Extension)";
-//                compile.AppendChild(link);
-//                compile.SetAttribute("Include", p);
-//                itemGroup.AppendChild(compile);
-//            }
+            XmlElement itemGroup = newDoc.CreateElement("ItemGroup", newDoc.DocumentElement.NamespaceURI);
+            foreach (var s in links)
+            {
+                string[] ss = s.Split(' ');
+                string p = ss[0];
+                string linkStr = ss[1];
+                XmlElement compile = newDoc.CreateElement("Compile", newDoc.DocumentElement.NamespaceURI);
+                XmlElement link = newDoc.CreateElement("Link", newDoc.DocumentElement.NamespaceURI);
+                link.InnerText = $"{linkStr}\\%(RecursiveDir)%(FileName)%(Extension)";
+                compile.AppendChild(link);
+                compile.SetAttribute("Include", p);
+                itemGroup.AppendChild(compile);
+            }
 
-//            var projectReference = newDoc.CreateElement("ProjectReference", newDoc.DocumentElement.NamespaceURI);
-//            projectReference.SetAttribute("Include", @"..\Codes\Analyzer\Share.Analyzer.csproj");
-//            projectReference.SetAttribute("OutputItemType", @"Analyzer");
-//            projectReference.SetAttribute("ReferenceOutputAssembly", @"false");
+            var projectReference = newDoc.CreateElement("ProjectReference", newDoc.DocumentElement.NamespaceURI);
+            projectReference.SetAttribute("Include", @"..\Codes\Analyzer\Share.Analyzer.csproj");
+            projectReference.SetAttribute("OutputItemType", @"Analyzer");
+            projectReference.SetAttribute("ReferenceOutputAssembly", @"false");
 
-//            var project = newDoc.CreateElement("Project", newDoc.DocumentElement.NamespaceURI);
-//            project.InnerText = @"{d1f2986b-b296-4a2d-8f12-be9f470014c3}";
-//            projectReference.AppendChild(project);
+            var project = newDoc.CreateElement("Project", newDoc.DocumentElement.NamespaceURI);
+            project.InnerText = @"{d1f2986b-b296-4a2d-8f12-be9f470014c3}";
+            projectReference.AppendChild(project);
 
-//            var name = newDoc.CreateElement("Name", newDoc.DocumentElement.NamespaceURI);
-//            name.InnerText = "Analyzer";
-//            projectReference.AppendChild(project);
+            var name = newDoc.CreateElement("Name", newDoc.DocumentElement.NamespaceURI);
+            name.InnerText = "Analyzer";
+            projectReference.AppendChild(project);
 
-//            itemGroup.AppendChild(projectReference);
+            itemGroup.AppendChild(projectReference);
 
-//            rootNode.AppendChild(itemGroup);
+            rootNode.AppendChild(itemGroup);
 
-//            using (StringWriter sw = new StringWriter())
-//            {
+            using (StringWriter sw = new StringWriter())
+            {
 
-//                using (XmlTextWriter tx = new XmlTextWriter(sw))
-//                {
-//                    tx.Formatting = Formatting.Indented;
-//                    newDoc.WriteTo(tx);
-//                    tx.Flush();
-//                    return sw.GetStringBuilder().ToString();
-//                }
-//            }
-//        }
-//    }
-//}
+                using (XmlTextWriter tx = new XmlTextWriter(sw))
+                {
+                    tx.Formatting = Formatting.Indented;
+                    newDoc.WriteTo(tx);
+                    tx.Flush();
+                    return sw.GetStringBuilder().ToString();
+                }
+            }
+        }
+    }
+}

+ 7 - 7
Unity/Assets/Scripts/Editor/CodesListener/CodesListenerExecutor.cs

@@ -14,34 +14,34 @@ public class CodesListenerExecutor
     }
     public static void Refresh()
     {
-        //客户端Model
+        //瀹㈡埛绔疢odel
         RegisterCodeFolder(CodeClass.Client, 
             "Unity.Model.csproj", "../Codes", 
             new Dictionary<string, List<string>>() { 
                 { "Model", new List<string>() { "Client", "Share" } }, 
                 { "Generate", new List<string> { "Client", "Share" } } });
-        //客户端Hotfix
+        //瀹㈡埛绔疕otfix
         RegisterCodeFolder(CodeClass.Client, 
             "Unity.Hotfix.csproj", "../Codes", 
             new Dictionary<string, List<string>>() { 
                 { "Hotfix", new List<string>() { "Client", "Share" } } });
-        //客户端ModelView
+        //瀹㈡埛绔疢odelView
         RegisterCodeFolder(CodeClass.Client, 
             "Unity.ModelView.csproj", "../Codes", 
             new Dictionary<string, List<string>>() { 
                 { "ModelView", new List<string>() { "Client" } } });
-        //客户端HotfixView
+        //瀹㈡埛绔疕otfixView
         RegisterCodeFolder(CodeClass.Client, 
             "Unity.HotfixView.csproj", "../Codes", 
             new Dictionary<string, List<string>>() { 
                 { "HotfixView", new List<string>() { "Client" } } });
-        //服务端Model
+        //鏈嶅姟绔疢odel
         RegisterCodeFolder(CodeClass.Server, 
             "../DotNet/Model/DotNet.Model.csproj", "../Codes", 
             new Dictionary<string, List<string>>() { 
                 { "Model", new List<string>() { "Server", "Share" ,"Client"} }, 
                 { "Generate", new List<string> { "Server", "Share" } } });
-        //服务端Hotfix
+        //鏈嶅姟绔疕otfix
         RegisterCodeFolder(CodeClass.Server, 
             "../DotNet/Hotfix/DotNet.Hotfix.csproj", "../Codes", 
             new Dictionary<string, List<string>>() { 
@@ -97,7 +97,7 @@ public class CodesListenerExecutor
         {
             if (depth == 0 && asmNames.Keys.Contains(dir.Name))
             {
-                //第一层通过,进入第二层
+                //绗�竴灞傞€氳繃锛岃繘鍏ョ�浜屽眰
                 GetAssemblyCodeFiles(dir, files, asmNames, dir.Name, 1);
             }
             else if (depth == 1 && asmNames.TryGetValue(key, out var second) && second.Contains(dir.Name))

+ 8 - 8
Unity/Assets/Scripts/Editor/CodesListener/ETProjectBrowser.cs

@@ -8,7 +8,7 @@ using UnityEditor.Build.Content;
 using UnityEngine;
 public class ETProjectBrowser : EditorWindow
 {
-    [MenuItem("ET/ET Project")]
+    //[MenuItem("ET/ET Project")]
     public static ETProjectBrowser Open()
     {
         var window = GetWindow<ETProjectBrowser>("ET Project");
@@ -56,7 +56,7 @@ public class ETProjectBrowser : EditorWindow
     {
         if (_settings == null)
         {
-            if (GUILayout.Button("请创建配置文件"))
+            if (GUILayout.Button("璇峰垱寤洪厤缃�枃浠�"))
             {
                 FileInfo fi = new FileInfo(_settingsAssetPath);
                 if (!fi.Directory.Exists)
@@ -71,17 +71,17 @@ public class ETProjectBrowser : EditorWindow
         if (string.IsNullOrEmpty(_settings.ListenFolderPath))
         {
             GUILayout.BeginHorizontal();
-            GUILayout.Label("请至少指定一个ET Project目录");
+            GUILayout.Label("璇疯嚦灏戞寚瀹氫竴涓狤T Project鐩�綍");
             GUILayout.EndHorizontal();
             return;
         }
         else
         {
-            if (GUILayout.Button("刷新工程"))
+            if (GUILayout.Button("鍒锋柊宸ョ▼"))
             {
                 Refresh(true);
             }
-            _autoFresh = GUILayout.Toggle(_autoFresh, "开启自动刷新工程");
+            _autoFresh = GUILayout.Toggle(_autoFresh, "寮€鍚�嚜鍔ㄥ埛鏂板伐绋�");
             GUILayout.BeginHorizontal();
             _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
             int _ = 0;
@@ -109,7 +109,7 @@ public class ETProjectBrowser : EditorWindow
                 {
                     EditorGUILayout.BeginHorizontal();
                     GUILayout.Space(10 * node.Level);
-                    if (GUILayout.Button("", GUILayout.MaxWidth(20)))
+                    if (GUILayout.Button("鈥�", GUILayout.MaxWidth(20)))
                     {
                         Event evt = Event.current;
                         Vector2 pos = evt.mousePosition;
@@ -156,7 +156,7 @@ public class ETProjectBrowser : EditorWindow
                     }
                     EditorGUILayout.BeginHorizontal(style);
                     GUILayout.Space(10 * node.Level);
-                    if (GUILayout.Button("", GUILayout.MaxWidth(20)))
+                    if (GUILayout.Button("鈥�", GUILayout.MaxWidth(20)))
                     {
                         Event evt = Event.current;
                         Vector2 pos = evt.mousePosition;
@@ -226,7 +226,7 @@ public class ETProjectBrowser : EditorWindow
         {
             return;
         }
-        //深度优先,文件夹在上面
+        //娣卞害浼樺厛,鏂囦欢澶瑰湪涓婇潰
         foreach (string dir in Directory.GetDirectories(parent.FullName))
         {
             if (_ignoreDirs.Contains(Path.GetFileName(dir)))