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

open c# project工程的时候复制ET.sln到根目录

tanghai 1 год назад
Родитель
Сommit
8f1a2838d4

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

@@ -0,0 +1,31 @@
+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);
+    }
+  }
+}

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

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

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

@@ -0,0 +1,107 @@
+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);
+				}
+			}
+		}
+	}
+}

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

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

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

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

+ 25 - 2
Packages/packages-lock.json

@@ -1,11 +1,20 @@
 {
   "dependencies": {
-    "cn.etetet.init": {
-      "version": "file:cn.etetet.init",
+    "com.etetet.init": {
+      "version": "file:com.etetet.init",
       "depth": 0,
       "source": "embedded",
       "dependencies": {}
     },
+    "com.halodi.halodi-unity-package-registry-manager": {
+      "version": "file:com.halodi.halodi-unity-package-registry-manager",
+      "depth": 0,
+      "source": "embedded",
+      "dependencies": {
+        "com.unity.nuget.newtonsoft-json": "3.0.2",
+        "com.unity.sharp-zip-lib": "1.3.4-preview"
+      }
+    },
     "com.unity.ai.navigation": {
       "version": "1.1.5",
       "depth": 0,
@@ -62,6 +71,13 @@
       "dependencies": {},
       "url": "https://packages.unity.com"
     },
+    "com.unity.nuget.newtonsoft-json": {
+      "version": "3.2.1",
+      "depth": 1,
+      "source": "registry",
+      "dependencies": {},
+      "url": "https://packages.unity.com"
+    },
     "com.unity.render-pipelines.core": {
       "version": "14.0.9",
       "depth": 1,
@@ -109,6 +125,13 @@
         "com.unity.searcher": "4.9.2"
       }
     },
+    "com.unity.sharp-zip-lib": {
+      "version": "1.3.4-preview",
+      "depth": 1,
+      "source": "registry",
+      "dependencies": {},
+      "url": "https://packages.unity.com"
+    },
     "com.unity.test-framework": {
       "version": "1.1.33",
       "depth": 1,

+ 11 - 3
ProjectSettings/PackageManagerSettings.asset

@@ -34,11 +34,19 @@ MonoBehaviour:
     m_IsDefault: 0
     m_Capabilities: 0
     m_ConfigSource: 4
-  m_UserSelectedRegistryName: package.openupm.com
+  - m_Id: scoped:project:ET-Packages
+    m_Name: ET-Packages
+    m_Url: https://npm.pkg.github.com/@ET-Packages
+    m_Scopes:
+    - cn.etetet
+    m_IsDefault: 0
+    m_Capabilities: 0
+    m_ConfigSource: 4
+  m_UserSelectedRegistryName: ET-Packages
   m_UserAddingNewScopedRegistry: 0
   m_RegistryInfoDraft:
     m_Modified: 0
     m_ErrorMessage: 
-    m_UserModificationsInstanceId: -838
-    m_OriginalInstanceId: -842
+    m_UserModificationsInstanceId: -858
+    m_OriginalInstanceId: -862
   m_LoadAssets: 0