|
|
@@ -8,20 +8,29 @@ namespace ET
|
|
|
{
|
|
|
public class OnGenerateCSProjectProcessor: AssetPostprocessor
|
|
|
{
|
|
|
+ private static string[] deleteFile = new string[]
|
|
|
+ {
|
|
|
+ "Library/ScriptAssemblies/Unity.AllModel.dll",
|
|
|
+ "Library/ScriptAssemblies/Unity.AllHotfix.dll",
|
|
|
+ "Library/ScriptAssemblies/Unity.AllModel.pdb",
|
|
|
+ "Library/ScriptAssemblies/Unity.AllHotfix.pdb",
|
|
|
+ };
|
|
|
+
|
|
|
public static string OnGeneratedCSProject(string path, string content)
|
|
|
{
|
|
|
if (path.EndsWith("Unity.Core.csproj"))
|
|
|
{
|
|
|
return GenerateCustomProject(path, content);
|
|
|
}
|
|
|
+
|
|
|
+ GlobalConfig globalConfig = Resources.Load<GlobalConfig>("GlobalConfig");
|
|
|
|
|
|
- if (path.EndsWith("Unity.Codes.csproj"))
|
|
|
+ if (path.EndsWith("Unity.AllModel.csproj"))
|
|
|
{
|
|
|
- if (!Define.EnableCodes)
|
|
|
+ if (!Define.EnableDll)
|
|
|
{
|
|
|
return content;
|
|
|
}
|
|
|
- GlobalConfig globalConfig = Resources.Load<GlobalConfig>("GlobalConfig");
|
|
|
if (globalConfig.BuildType == BuildType.Release)
|
|
|
{
|
|
|
content = content.Replace("<Optimize>false</Optimize>", "<Optimize>true</Optimize>");
|
|
|
@@ -37,10 +46,7 @@ namespace ET
|
|
|
@"Assets\Scripts\Model\Client\**\*.cs Model\Client\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
@"Assets\Scripts\Model\Share\**\*.cs Model\Share\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
@"Assets\Scripts\Model\Generate\Client\**\*.cs Model\Generate\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
- @"Assets\Scripts\Hotfix\Client\**\*.cs Hotfix\Client\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
- @"Assets\Scripts\Hotfix\Share\**\*.cs Hotfix\Share\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
@"Assets\Scripts\ModelView\Client\**\*.cs ModelView\Client\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
- @"Assets\Scripts\HotfixView\Client\**\*.cs HotfixView\Client\%(RecursiveDir)%(FileName)%(Extension)"
|
|
|
};
|
|
|
break;
|
|
|
case CodeMode.ClientServer:
|
|
|
@@ -50,10 +56,52 @@ namespace ET
|
|
|
@"Assets\Scripts\Model\Client\**\*.cs Model\Client\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
@"Assets\Scripts\Model\Share\**\*.cs Model\Share\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
@"Assets\Scripts\Model\Generate\ClientServer\**\*.cs Model\Generate\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
+ @"Assets\Scripts\ModelView\Client\**\*.cs ModelView\Client\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ content = GenerateCustomProject(path, content, files);
|
|
|
+ content = content.Replace("<Target Name=\"AfterBuild\" />",
|
|
|
+ " <Target Name=\"PostBuild\" AfterTargets=\"PostBuildEvent\">\n" +
|
|
|
+ $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).dll\" DestinationFiles=\"$(ProjectDir)/{Define.CodeDir}/Model.dll.bytes\" ContinueOnError=\"false\" />\n" +
|
|
|
+ $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).pdb\" DestinationFiles=\"$(ProjectDir)/{Define.CodeDir}/Model.pdb.bytes\" ContinueOnError=\"false\" />\n" +
|
|
|
+ $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).dll\" DestinationFiles=\"$(ProjectDir)/{Define.BuildOutputDir}/Model.dll\" ContinueOnError=\"false\" />\n" +
|
|
|
+ $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).pdb\" DestinationFiles=\"$(ProjectDir)/{Define.BuildOutputDir}/Model.pdb\" ContinueOnError=\"false\" />\n" +
|
|
|
+ " </Target>\n");
|
|
|
+ return content;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (path.EndsWith("Unity.AllHotfix.csproj"))
|
|
|
+ {
|
|
|
+ if (!Define.EnableDll)
|
|
|
+ {
|
|
|
+ return content;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (globalConfig.BuildType == BuildType.Release)
|
|
|
+ {
|
|
|
+ content = content.Replace("<Optimize>false</Optimize>", "<Optimize>true</Optimize>");
|
|
|
+ content = content.Replace(";DEBUG;", ";");
|
|
|
+ }
|
|
|
+
|
|
|
+ string[] files = Array.Empty<string>();
|
|
|
+ switch (globalConfig.CodeMode)
|
|
|
+ {
|
|
|
+ case CodeMode.Client:
|
|
|
+ files = new[]
|
|
|
+ {
|
|
|
+ @"Assets\Scripts\Hotfix\Client\**\*.cs Hotfix\Client\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
+ @"Assets\Scripts\Hotfix\Share\**\*.cs Hotfix\Share\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
+ @"Assets\Scripts\HotfixView\Client\**\*.cs HotfixView\Client\%(RecursiveDir)%(FileName)%(Extension)"
|
|
|
+ };
|
|
|
+ break;
|
|
|
+ case CodeMode.ClientServer:
|
|
|
+ files = new[]
|
|
|
+ {
|
|
|
@"Assets\Scripts\Hotfix\Client\**\*.cs Hotfix\Client\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
@"Assets\Scripts\Hotfix\Server\**\*.cs Hotfix\Server\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
@"Assets\Scripts\Hotfix\Share\**\*.cs Hotfix\Share\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
- @"Assets\Scripts\ModelView\Client\**\*.cs ModelView\Client\%(RecursiveDir)%(FileName)%(Extension)",
|
|
|
@"Assets\Scripts\HotfixView\Client\**\*.cs HotfixView\Client\%(RecursiveDir)%(FileName)%(Extension)"
|
|
|
};
|
|
|
break;
|
|
|
@@ -62,13 +110,22 @@ namespace ET
|
|
|
content = GenerateCustomProject(path, content, files);
|
|
|
content = content.Replace("<Target Name=\"AfterBuild\" />",
|
|
|
" <Target Name=\"PostBuild\" AfterTargets=\"PostBuildEvent\">\n" +
|
|
|
- $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).dll\" DestinationFiles=\"$(ProjectDir)/{Define.CodeDir}/Codes.dll.bytes\" ContinueOnError=\"false\" />\n" +
|
|
|
- $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).pdb\" DestinationFiles=\"$(ProjectDir)/{Define.CodeDir}/Codes.pdb.bytes\" ContinueOnError=\"false\" />\n" +
|
|
|
- $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).dll\" DestinationFiles=\"$(ProjectDir)/{Define.BuildOutputDir}/Codes.dll\" ContinueOnError=\"false\" />\n" +
|
|
|
- $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).pdb\" DestinationFiles=\"$(ProjectDir)/{Define.BuildOutputDir}/Codes.pdb\" ContinueOnError=\"false\" />\n" +
|
|
|
+ $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).dll\" DestinationFiles=\"$(ProjectDir)/{Define.CodeDir}/Hotfix.dll.bytes\" ContinueOnError=\"false\" />\n" +
|
|
|
+ $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).pdb\" DestinationFiles=\"$(ProjectDir)/{Define.CodeDir}/Hotfix.pdb.bytes\" ContinueOnError=\"false\" />\n" +
|
|
|
+ $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).dll\" DestinationFiles=\"$(ProjectDir)/{Define.BuildOutputDir}/Hotfix.dll\" ContinueOnError=\"false\" />\n" +
|
|
|
+ $" <Copy SourceFiles=\"$(TargetDir)/$(TargetName).pdb\" DestinationFiles=\"$(ProjectDir)/{Define.BuildOutputDir}/Hotfix.pdb\" ContinueOnError=\"false\" />\n" +
|
|
|
" </Target>\n");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ foreach (string file in deleteFile)
|
|
|
+ {
|
|
|
+ if (File.Exists(file))
|
|
|
+ {
|
|
|
+ File.Delete(file);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return content;
|
|
|
}
|
|
|
|