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

1.客户端带上服务端成功!ET/BuildTool中,CodeMode改成ClientServer即可体验!
2.客户端生成的项目中带上了服务端代码,这个没什么问题,因为我们并不使用项目生成的dll而是使用ET/BuildTool生成的dll
3.ET/BuildTool 有个CodeMode,三个选项:
a.Client 仅编译客户端代码,仅做客户端使用
b.Server 仅编译服务端代码,可以把Unity打包成服务端,很多项目想用Unity当server,可以使用这种模式
c.ClientServer 编译客户端跟服务端代码,该模式下,客户端里面带有一个服务端,可以自己连接自己身上的服务端,就不用额外启动一个服务端了

tanghai 3 лет назад
Родитель
Сommit
4e5af41c8c

+ 4 - 2
Codes/Hotfix/Server/Module/DB/DBComponentSystem.cs

@@ -1,4 +1,5 @@
-using System;
+#if !UNITY_64
+using System;
 using System.Collections.Generic;
 using System.Linq.Expressions;
 using MongoDB.Driver;
@@ -249,4 +250,5 @@ namespace ET.Server
 
 	    #endregion
     }
-}
+}
+#endif

+ 4 - 2
Codes/Hotfix/Server/Module/DB/DBManagerComponentSystem.cs

@@ -1,4 +1,5 @@
-using System;
+#if !UNITY_64
+using System;
 
 namespace ET.Server
 {
@@ -42,4 +43,5 @@ namespace ET.Server
             return dbComponent;
         }
     }
-}
+}
+#endif

+ 4 - 2
Codes/Model/Server/Module/DB/DBComponent.cs

@@ -1,4 +1,5 @@
-using MongoDB.Driver;
+#if !UNITY_64
+using MongoDB.Driver;
 
 namespace ET.Server
 {
@@ -13,4 +14,5 @@ namespace ET.Server
         public MongoClient mongoClient;
         public IMongoDatabase database;
     }
-}
+}
+#endif

+ 4 - 2
Codes/Model/Server/Module/DB/DBManagerComponent.cs

@@ -1,4 +1,5 @@
-namespace ET.Server
+#if !UNITY_64
+namespace ET.Server
 {
     
     public class DBManagerComponent: Entity, IAwake, IDestroy
@@ -7,4 +8,5 @@
         
         public DBComponent[] DBComponents = new DBComponent[IdGenerater.MaxZone];
     }
-}
+}
+#endif

+ 3 - 1
Codes/Model/Server/Module/DB/IDBCollection.cs

@@ -1,6 +1,8 @@
+#if !UNITY_64
 namespace ET.Server
 {
     public interface IDBCollection
     {
     }
-}
+}
+#endif

+ 7 - 3
Unity/Assets/Scripts/Editor/AssetPostProcessor/OnGenerateCSProjectProcessor.cs

@@ -40,7 +40,9 @@ namespace ET
             {
                 return GenerateCustomProject(path, content, 
                     @"..\Codes\Hotfix\Client\**\*.cs Client", 
-                    @"..\Codes\Hotfix\Share\**\*.cs Share");
+                    @"..\Codes\Hotfix\Share\**\*.cs Share",
+                    @"..\Codes\Hotfix\Server\**\*.cs Server"
+                    );
             }
 
             if (path.EndsWith("Unity.HotfixView.csproj"))
@@ -52,10 +54,12 @@ namespace ET
 
             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\Client\**\*.cs Generate");
+                    @"..\Codes\Generate\Server\**\*.cs Generate"
+                    );
             }
 
             if (path.EndsWith("Unity.ModelView.csproj"))

+ 1 - 3
Unity/Assets/Scripts/Editor/BuildEditor/BuildAssemblieEditor.cs

@@ -55,14 +55,13 @@ namespace ET
                 case CodeMode.ClientServer:
                     codes = new List<string>()
                     {
-                        "../Codes/Generate/Client/",
+                        "../Codes/Generate/Server/",
                         "../Codes/Model/Share/",
                         "../Codes/Hotfix/Share/",
                         "../Codes/Model/Client/",
                         "../Codes/ModelView/Client/",
                         "../Codes/Hotfix/Client/",
                         "../Codes/HotfixView/Client/",
-                        "../Codes/Generate/Server/",
                         "../Codes/Model/Server/",
                         "../Codes/Hotfix/Server/",
                     };
@@ -104,7 +103,6 @@ namespace ET
                 case CodeMode.ClientServer:
                     codes = new List<string>()
                     {
-                        "../Codes/Generate/Client/",
                         "../Codes/Model/Share/",
                         "../Codes/Model/Client/",
                         "../Codes/ModelView/Client/",