Kaynağa Gözat

插件机制,Codes增加Plugins目录,里面可以放大家写好的插件,仿照Example目录防止就行了,会自动引用代码

tanghai 3 yıl önce
ebeveyn
işleme
13902357fb

+ 0 - 0
Codes/Plugins/Example/Hotfix/Client/HotfixClient.cs


+ 0 - 0
Codes/Plugins/Example/Hotfix/Server/HotfixServer.cs


+ 0 - 0
Codes/Plugins/Example/Hotfix/Share/HotfixShare.cs


+ 0 - 0
Codes/Plugins/Example/HotfixView/Client/HotfixView.cs


+ 0 - 0
Codes/Plugins/Example/Model/Client/ModelClient.cs


+ 0 - 0
Codes/Plugins/Example/Model/Server/ModelServer.cs


+ 0 - 0
Codes/Plugins/Example/Model/Share/ModelShare.cs


+ 0 - 0
Codes/Plugins/Example/ModelView/Client/ModelView.cs


+ 12 - 0
DotNet/Hotfix/DotNet.Hotfix.csproj

@@ -21,6 +21,18 @@
     </PropertyGroup>
     </PropertyGroup>
     <ItemGroup>
     <ItemGroup>
 
 
+        <Compile Include="..\..\Codes\Plugins\*\Hotfix\Server\**\*.cs">
+            <Link>Server\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Hotfix\Server', ''))%(FileName)%(Extension)</Link>
+        </Compile>
+
+        <Compile Include="..\..\Codes\Plugins\*\Hotfix\Client\**\*.cs">
+            <Link>Client\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Hotfix\Client', ''))%(FileName)%(Extension)</Link>
+        </Compile>
+
+        <Compile Include="..\..\Codes\Plugins\*\Hotfix\Share\**\*.cs">
+            <Link>Share\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Hotfix\Share',''))%(FileName)%(Extension)</Link>
+        </Compile>
+
         <Compile Include="..\..\Codes\Hotfix\Client\**\*.cs">
         <Compile Include="..\..\Codes\Hotfix\Client\**\*.cs">
             <Link>Client\%(RecursiveDir)%(FileName)%(Extension)</Link>
             <Link>Client\%(RecursiveDir)%(FileName)%(Extension)</Link>
         </Compile> 
         </Compile> 

+ 14 - 1
DotNet/Model/DotNet.Model.csproj

@@ -19,10 +19,23 @@
         <DefineConstants>DOTNET</DefineConstants>
         <DefineConstants>DOTNET</DefineConstants>
         <OutputPath>..\..\Bin\</OutputPath>
         <OutputPath>..\..\Bin\</OutputPath>
         <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
         <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-        <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+        <TreatWarningsAsErrors>true</TreatWarningsAsErrors> 
     </PropertyGroup>
     </PropertyGroup>
     <ItemGroup>
     <ItemGroup>
 
 
+        <Compile Include="..\..\Codes\Plugins\*\Model\Server\**\*.cs">
+            <Link>Server\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Model\Server',''))%(FileName)%(Extension)</Link>
+        </Compile>
+
+        <Compile Include="..\..\Codes\Plugins\*\Model\Client\**\*.cs">
+            <Link>Client\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Model\Client',''))%(FileName)%(Extension)</Link>
+        </Compile>
+
+
+        <Compile Include="..\..\Codes\Plugins\*\Model\Share\**\*.cs">
+            <Link>Share\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Model\Share',''))%(FileName)%(Extension)</Link>
+        </Compile>
+
         <Compile Include="..\..\Unity\Assets\Mono\Core\**\*.cs">
         <Compile Include="..\..\Unity\Assets\Mono\Core\**\*.cs">
             <Link>Core\%(RecursiveDir)%(FileName)%(Extension)</Link>  
             <Link>Core\%(RecursiveDir)%(FileName)%(Extension)</Link>  
         </Compile> 
         </Compile> 

+ 23 - 14
Unity/Assets/Scripts/Editor/AssetPostProcessor/OnGenerateCSProjectProcessor.cs

@@ -39,36 +39,45 @@ namespace ET
             if (path.EndsWith("Unity.Hotfix.csproj"))
             if (path.EndsWith("Unity.Hotfix.csproj"))
             {
             {
                 return GenerateCustomProject(path, content, 
                 return GenerateCustomProject(path, content, 
-                    @"..\Codes\Hotfix\Client\**\*.cs Client", 
-                    @"..\Codes\Hotfix\Share\**\*.cs Share",
-                    @"..\Codes\Hotfix\Server\**\*.cs Server"
+                    @"..\Codes\Hotfix\Client\**\*.cs Client\%(RecursiveDir)%(FileName)%(Extension)", 
+                    @"..\Codes\Hotfix\Share\**\*.cs Share\%(RecursiveDir)%(FileName)%(Extension)",
+                    @"..\Codes\Hotfix\Server\**\*.cs Server\%(RecursiveDir)%(FileName)%(Extension)",
+                    @"..\Codes\Plugins\*\Hotfix\Client\**\*.cs Client\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Hotfix\Client',''))%(FileName)%(Extension)",
+                    @"..\Codes\Plugins\*\Hotfix\Share\**\*.cs Share\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Hotfix\Share',''))%(FileName)%(Extension)",
+                    @"..\Codes\Plugins\*\Hotfix\Server\**\*.cs Server\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Hotfix\Server',''))%(FileName)%(Extension)"
                     );
                     );
             }
             }
 
 
             if (path.EndsWith("Unity.HotfixView.csproj"))
             if (path.EndsWith("Unity.HotfixView.csproj"))
             {
             {
                 return GenerateCustomProject(path, content, 
                 return GenerateCustomProject(path, content, 
-                    @"..\Codes\HotfixView\Client\**\*.cs Client", 
-                    @"..\Codes\HotfixView\Share\**\*.cs Share"); 
+                    @"..\Codes\HotfixView\Client\**\*.cs Client\%(RecursiveDir)%(FileName)%(Extension)", 
+                    @"..\Codes\HotfixView\Share\**\*.cs Share\%(RecursiveDir)%(FileName)%(Extension)",
+                    @"..\Codes\Plugins\*\HotfixView\Client\**\*.cs Client\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('HotfixView\Client',''))%(FileName)%(Extension)"
+                    ); 
             }
             }
 
 
             if (path.EndsWith("Unity.Model.csproj"))
             if (path.EndsWith("Unity.Model.csproj"))
             {
             {
                 return GenerateCustomProject(path, content,
                 return GenerateCustomProject(path, content,
-                    @"..\Codes\Model\Server\**\*.cs Server",
-                    @"..\Codes\Model\Client\**\*.cs Client",
-                    @"..\Codes\Model\Share\**\*.cs Share",
-                    @"..\Codes\Generate\Server\**\*.cs Generate"
+                    @"..\Codes\Model\Server\**\*.cs Server\%(RecursiveDir)%(FileName)%(Extension)",
+                    @"..\Codes\Model\Client\**\*.cs Client\%(RecursiveDir)%(FileName)%(Extension)",
+                    @"..\Codes\Model\Share\**\*.cs Share\%(RecursiveDir)%(FileName)%(Extension)",
+                    @"..\Codes\Generate\Server\**\*.cs Generate\%(RecursiveDir)%(FileName)%(Extension)",
+                    @"..\Codes\Plugins\*\Model\Client\**\*.cs Client\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Model\Client',''))%(FileName)%(Extension)",
+                    @"..\Codes\Plugins\*\Model\Share\**\*.cs Share\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Model\Share',''))%(FileName)%(Extension)",
+                    @"..\Codes\Plugins\*\Model\Server\**\*.cs Server\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('Model\Server',''))%(FileName)%(Extension)"
                     );
                     );
             }
             }
 
 
             if (path.EndsWith("Unity.ModelView.csproj"))
             if (path.EndsWith("Unity.ModelView.csproj"))
             {
             {
-                return GenerateCustomProject(path, content, 
-                    @"..\Codes\ModelView\Client\**\*.cs Client",
-                    @"..\Codes\ModelView\Share\**\*.cs Share");
+                return GenerateCustomProject(path, content,
+                    @"..\Codes\ModelView\Client\**\*.cs Client\%(RecursiveDir)%(FileName)%(Extension)",
+                    @"..\Codes\ModelView\Share\**\*.cs Share\%(RecursiveDir)%(FileName)%(Extension)",
+                    @"..\Codes\Plugins\*\ModelView\Client\**\*.cs Share\Plugins\$([System.String]::new(%(RecursiveDir)).Replace('ModelView\Client',''))%(FileName)%(Extension)"
+                    );
             }
             }
-          
             return content;
             return content;
         }
         }
 
 
@@ -89,7 +98,7 @@ namespace ET
                 string linkStr = ss[1];
                 string linkStr = ss[1];
                 XmlElement compile = newDoc.CreateElement("Compile", newDoc.DocumentElement.NamespaceURI);
                 XmlElement compile = newDoc.CreateElement("Compile", newDoc.DocumentElement.NamespaceURI);
                 XmlElement link = newDoc.CreateElement("Link", newDoc.DocumentElement.NamespaceURI);
                 XmlElement link = newDoc.CreateElement("Link", newDoc.DocumentElement.NamespaceURI);
-                link.InnerText = $"{linkStr}\\%(RecursiveDir)%(FileName)%(Extension)";
+                link.InnerText = linkStr;
                 compile.AppendChild(link);
                 compile.AppendChild(link);
                 compile.SetAttribute("Include", p);
                 compile.SetAttribute("Include", p);
                 itemGroup.AppendChild(compile);
                 itemGroup.AppendChild(compile);