Sfoglia il codice sorgente

客户端Hotfix Model ModelView HotfixView自动引用代码

tanghai 1 anno fa
parent
commit
acae176db7

+ 3 - 3
Share/Share.SourceGenerator/Share.SourceGenerator.csproj

@@ -30,8 +30,8 @@
         </PackageReference>
     </ItemGroup>
 
-    <Target Name="PostBuild" AfterTargets="PostBuildEvent">
-        <Copy SourceFiles="$(TargetDir)/$(TargetName).dll" DestinationFolder="$(ProjectDir)/../../Unity/Packages/com.et.core/Plugins/" ContinueOnError="false" />
-    </Target>
+<!--    <Target Name="PostBuild" AfterTargets="PostBuildEvent">-->
+<!--        <Copy SourceFiles="$(TargetDir)/$(TargetName).dll" DestinationFolder="$(ProjectDir)/../../Unity/Packages/com.et.core/Plugins/" ContinueOnError="false" />-->
+<!--    </Target>-->
 
 </Project>

+ 0 - 8
Unity/Assets/Scripts/Hotfix/Server.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 4de2920d40637e64bbf60a4166b82b5f
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 2 - 1
Unity/Assets/Scripts/Hotfix/Unity.Hotfix.asmdef

@@ -5,7 +5,8 @@
         "Unity.Core",
         "Unity.Mathematics",
         "MemoryPack",
-        "Unity.Model"
+        "Unity.Model",
+        "Unity.ThirdParty"
     ],
     "includePlatforms": [],
     "excludePlatforms": [],

+ 0 - 8
Unity/Assets/Scripts/Model/Server.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: c978be66d7808f9438f2c8cbd7a5ccfe
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 8
Unity/Assets/Scripts/Model/Share.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 3b0871f1e2b4248408dba0b28965c04a
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 37 - 6
Unity/Packages/com.et.loader/Scripts/Editor/AssetPostProcessor/OnGenerateCSProjectProcessor.cs

@@ -28,14 +28,23 @@ namespace ET
                 return GenerateCustomProject(content);
             }
 
-            if (path.EndsWith("Unity.Model.csproj") || path.EndsWith("Unity.Hotfix.csproj"))
+            if (path.EndsWith("Unity.Model.csproj"))
             {
-                return AddCopyAfterBuild(GenerateCustomProject(content));
+                return AddCopyAfterBuild(GenerateCustomProject(content), "Model");
+            }
+            
+            if (path.EndsWith("Unity.Hotfix.csproj"))
+            {
+                return AddCopyAfterBuild(GenerateCustomProject(content), "Hotfix");
             }
 
-            if (path.EndsWith("Unity.ModelView.csproj") || path.EndsWith("Unity.HotfixView.csproj"))
+            if (path.EndsWith("Unity.ModelView.csproj"))
             {
-                return AddCopyAfterBuild(GenerateCustomProject(content));
+                return AddCopyAfterBuild(GenerateCustomProject(content), "ModelView");
+            }
+            if (path.EndsWith("Unity.HotfixView.csproj"))
+            {
+                return AddCopyAfterBuild(GenerateCustomProject(content), "HotfixView");
             }
 
             return content;
@@ -116,15 +125,37 @@ namespace ET
         /// <summary>
         /// 编译dll文件后额外复制的目录配置
         /// </summary>
-        static string AddCopyAfterBuild(string content)
+        static string AddCopyAfterBuild(string content, string dllName)
         {
-            return content.Replace("<Target Name=\"AfterBuild\" />",
+            content = content.Replace("<None Include=\"Assets\\Scripts\\" + dllName + "\\Unity." + dllName + ".asmdef\" />", "");
+            content = content.Replace("<Target Name=\"AfterBuild\" />",
                 "<Target Name=\"PostBuild\" AfterTargets=\"PostBuildEvent\">\n" +
                 $"    <Copy SourceFiles=\"$(TargetDir)/$(TargetName).dll\" DestinationFiles=\"$(ProjectDir)/{Define.CodeDir}/$(TargetName).dll.bytes\" ContinueOnError=\"false\" />\n" +
                 $"    <Copy SourceFiles=\"$(TargetDir)/$(TargetName).pdb\" DestinationFiles=\"$(ProjectDir)/{Define.CodeDir}/$(TargetName).pdb.bytes\" ContinueOnError=\"false\" />\n" +
                 $"    <Copy SourceFiles=\"$(TargetDir)/$(TargetName).dll\" DestinationFiles=\"$(ProjectDir)/{Define.BuildOutputDir}/$(TargetName).dll\" ContinueOnError=\"false\" />\n" +
                 $"    <Copy SourceFiles=\"$(TargetDir)/$(TargetName).pdb\" DestinationFiles=\"$(ProjectDir)/{Define.BuildOutputDir}/$(TargetName).pdb\" ContinueOnError=\"false\" />\n" +
                 "  </Target>\n");
+            content = content.Replace("<Compile Include=\"Assets\\Scripts\\" + dllName + "\\Empty.cs\" />", 
+                "<Compile Include=\"Library\\PackageCache\\com.et.*\\Scripts\\" + dllName + "~\\Share\\**\\*.cs\">\n            " +
+                "<Link>Share/$([System.String]::new(%(RecursiveDir)).Substring(7, $([System.String]::new(%(RecursiveDir)).Indexof(\"Scripts\"))).Replace(\"Scripts\", \"\"))/%(FileName)%(Extension)</Link>\n        " +
+                "</Compile>\n\n        " +
+                "<Compile Include=\"Library\\PackageCache\\com.et.*\\Scripts\\" + dllName + "~\\Client\\**\\*.cs\">\n            " +
+                "<Link>Client/$([System.String]::new(%(RecursiveDir)).Substring(7, $([System.String]::new(%(RecursiveDir)).Indexof(\"Scripts\"))).Replace(\"Scripts\", \"\"))/%(FileName)%(Extension)</Link>\n        " +
+                "</Compile>\n\n        " +
+                "<Compile Include=\"Library\\PackageCache\\com.et.*\\Scripts\\" + dllName + "~\\Server\\**\\*.cs\">\n            " +
+                "<Link>Server/$([System.String]::new(%(RecursiveDir)).Substring(7, $([System.String]::new(%(RecursiveDir)).Indexof(\"Scripts\"))).Replace(\"Scripts\", \"\"))/%(FileName)%(Extension)</Link>\n        " +
+                "</Compile>\n\n        " +
+                "<Compile Include=\"Packages\\com.et.*\\Scripts\\" + dllName + "~\\Share\\**\\*.cs\">\n            " +
+                "<Link>Share/$([System.String]::new(%(RecursiveDir)).Substring(7, $([System.String]::new(%(RecursiveDir)).Indexof(\"Scripts\"))).Replace(\"Scripts\", \"\"))/%(FileName)%(Extension)</Link>\n        " +
+                "</Compile>\n\n        " +
+                "<Compile Include=\"Packages\\com.et.*\\Scripts\\" + dllName + "~\\Client\\**\\*.cs\">\n            " +
+                "<Link>Client/$([System.String]::new(%(RecursiveDir)).Substring(7, $([System.String]::new(%(RecursiveDir)).Indexof(\"Scripts\"))).Replace(\"Scripts\", \"\"))/%(FileName)%(Extension)</Link>\n        " +
+                "</Compile>\n\n        " +
+                "<Compile Include=\"Packages\\com.et.*\\Scripts\\" + dllName + "~\\Server\\**\\*.cs\">\n            " +
+                "<Link>Server/$([System.String]::new(%(RecursiveDir)).Substring(7, $([System.String]::new(%(RecursiveDir)).Indexof(\"Scripts\"))).Replace(\"Scripts\", \"\"))/%(FileName)%(Extension)</Link>\n        " +
+                "</Compile>"
+                );
+            return content;
         }
 
         /// <summary>