Przeglądaj źródła

复制ET.sln的操作放到Init中去

tanghai 1 rok temu
rodzic
commit
a37b7f5329

+ 8 - 2
Packages/com.etetet.init/Editor/PackagesEditor/InitHelper.cs

@@ -21,14 +21,21 @@ namespace ET
         [MenuItem("ET/Init")]
         public static void Init()
         {
+            LinkSlnHelper.Run();
+            
             ToolsEditor.ExcelExporter();
             
             ToolsEditor.Proto2CS();
             
-            Refresh();
+            AsmdefEditor.UpdateAssemblyDefinition();
+            
+            GlobalConfig globalConfig = AssetDatabase.LoadAssetAtPath<GlobalConfig>("Packages/com.etetet.init/Resources/GlobalConfig.asset");
+            CodeModeChangeHelper.ChangeToCodeMode(globalConfig.CodeMode);
             
             DefineHelper.EnableDefineSymbols("INITED", true);
             
+            AssetDatabase.Refresh();
+            
             Debug.Log("Init finish!");
         }
 
@@ -40,7 +47,6 @@ namespace ET
             GlobalConfig globalConfig = AssetDatabase.LoadAssetAtPath<GlobalConfig>("Packages/com.etetet.init/Resources/GlobalConfig.asset");
             CodeModeChangeHelper.ChangeToCodeMode(globalConfig.CodeMode);
             
-            
             AssetDatabase.Refresh();
             Debug.Log("packages refresh finish!");
         }

+ 36 - 0
Packages/com.etetet.init/Editor/PackagesEditor/LinkSlnHelper.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using UnityEditor;
+
+namespace ET
+{
+    public static class LinkSlnHelper
+    {
+        [MenuItem("ET/LinkSln")]
+        public static void Run()
+        {
+            string etslnPath = Path.Combine(Directory.GetCurrentDirectory(), "ET.sln");
+            if (File.Exists(etslnPath))
+            {
+                File.Delete(etslnPath);
+            }
+            
+            List<string> slns = new List<string>();
+            FileHelper.GetAllFiles(slns, "./Packages", "ET.sln");
+
+            if (slns.Count == 0)
+            {
+                throw new Exception("not found ET.sln in et packages!");
+            }
+            
+#if UNITY_EDITOR_WIN
+            Process process = ProcessHelper.Run("powershell.exe", $"New-Item -ItemType HardLink -Target {slns[0]} ./ET.sln", waitExit: true);
+#else
+            Process process = ProcessHelper.Run("pwsh", $"New-Item -ItemType HardLink -Target {slns[0]} ./ET.sln", waitExit: true);
+#endif
+            UnityEngine.Debug.Log(process.StandardOutput.ReadToEnd());
+        }
+    }
+}

+ 3 - 0
Packages/com.etetet.init/Editor/PackagesEditor/LinkSlnHelper.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 36c031aed09f48cc9094dd617fe6ffbd
+timeCreated: 1719990868

+ 0 - 31
Packages/com.unity.ide.rider@3.0.28/Rider/Editor/ProjectGeneration/CopyETslnHelper.cs

@@ -1,31 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using UnityEditor;
-
-namespace ET
-{
-  public static class CopyETslnHelper
-  {
-    public static void Run()
-    {
-      string etslnPath = Path.Combine(Directory.GetCurrentDirectory(), "ET.sln");
-      if (File.Exists(etslnPath))
-      {
-        return;
-      }
-            
-      List<string> slns = new List<string>();
-      FileHelper.GetAllFiles(slns, "./Packages", "ET.sln");
-
-      if (slns.Count == 0)
-      {
-        return;
-      }
-
-      string sourcePath = slns[0];
-
-      File.Copy(sourcePath, etslnPath, true);
-    }
-  }
-}

+ 0 - 3
Packages/com.unity.ide.rider@3.0.28/Rider/Editor/ProjectGeneration/CopyETslnHelper.cs.meta

@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: 4228119f865847e3ac1090fd21d9d776
-timeCreated: 1719545575

+ 0 - 107
Packages/com.unity.ide.rider@3.0.28/Rider/Editor/ProjectGeneration/FileHelper.cs

@@ -1,107 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-
-namespace ET
-{
-	public static class FileHelper
-	{
-		public static List<string> GetAllFiles(string dir, string searchPattern = "*")
-		{
-			List<string> list = new List<string>();
-			GetAllFiles(list, dir, searchPattern);
-			return list;
-		}
-		
-		public static void GetAllFiles(List<string> files, string dir, string searchPattern = "*")
-		{
-			string[] fls = Directory.GetFiles(dir, searchPattern);
-			foreach (string fl in fls)
-			{
-				files.Add(fl);
-			}
-
-			string[] subDirs = Directory.GetDirectories(dir);
-			foreach (string subDir in subDirs)
-			{
-				GetAllFiles(files, subDir, searchPattern);
-			}
-		}
-		
-		public static void CleanDirectory(string dir)
-		{
-			if (!Directory.Exists(dir))
-			{
-				return;
-			}
-			foreach (string subdir in Directory.GetDirectories(dir))
-			{
-				Directory.Delete(subdir, true);		
-			}
-
-			foreach (string subFile in Directory.GetFiles(dir))
-			{
-				File.Delete(subFile);
-			}
-		}
-
-		public static void CopyDirectory(string srcDir, string tgtDir)
-		{
-			DirectoryInfo source = new DirectoryInfo(srcDir);
-			DirectoryInfo target = new DirectoryInfo(tgtDir);
-	
-			if (target.FullName.StartsWith(source.FullName, StringComparison.CurrentCultureIgnoreCase))
-			{
-				throw new Exception("父目录不能拷贝到子目录!");
-			}
-	
-			if (!source.Exists)
-			{
-				return;
-			}
-	
-			if (!target.Exists)
-			{
-				target.Create();
-			}
-	
-			FileInfo[] files = source.GetFiles();
-	
-			for (int i = 0; i < files.Length; i++)
-			{
-				File.Copy(files[i].FullName, Path.Combine(target.FullName, files[i].Name), true);
-			}
-	
-			DirectoryInfo[] dirs = source.GetDirectories();
-	
-			for (int j = 0; j < dirs.Length; j++)
-			{
-				CopyDirectory(dirs[j].FullName, Path.Combine(target.FullName, dirs[j].Name));
-			}
-		}
-		
-		public static void ReplaceExtensionName(string srcDir, string extensionName, string newExtensionName)
-		{
-			if (Directory.Exists(srcDir))
-			{
-				string[] fls = Directory.GetFiles(srcDir);
-
-				foreach (string fl in fls)
-				{
-					if (fl.EndsWith(extensionName))
-					{
-						File.Move(fl, fl.Substring(0, fl.IndexOf(extensionName)) + newExtensionName);
-						File.Delete(fl);
-					}
-				}
-
-				string[] subDirs = Directory.GetDirectories(srcDir);
-
-				foreach (string subDir in subDirs)
-				{
-					ReplaceExtensionName(subDir, extensionName, newExtensionName);
-				}
-			}
-		}
-	}
-}

+ 0 - 3
Packages/com.unity.ide.rider@3.0.28/Rider/Editor/ProjectGeneration/FileHelper.cs.meta

@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: c07d4d4cf6134d26af65bfa355781a5f
-timeCreated: 1719545553

+ 0 - 2
Packages/com.unity.ide.rider@3.0.28/Rider/Editor/RiderScriptEditor.cs

@@ -336,8 +336,6 @@ namespace Packages.Rider.Editor
       //  return solutionFile;
       //}
 
-      ET.CopyETslnHelper.Run();
-
       return "ET.sln";
     }