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

1.整理了配置加载相关代码
2.proto增加map支持
3.整理了序列化相关代码

tanghai 3 лет назад
Родитель
Сommit
e3bd1202fa
39 измененных файлов с 419 добавлено и 405 удалено
  1. 5 5
      DotNet/App/ConfigLoader.cs
  2. 1 3
      DotNet/App/ReloadDllConsoleHandler.cs
  3. 2 1
      Share/Tool/Init.cs
  4. 24 2
      Share/Tool/Proto2CS/Proto2CS.cs
  5. 2 3
      Unity/Assets/Config/Proto/OuterMessage_C_10001.proto
  6. 5 4
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Unit/UnitFactory.cs
  7. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs
  8. 2 4
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit/UnitHelper.cs
  9. 8 11
      Unity/Assets/Scripts/Codes/Model/Generate/Client/Message/OuterMessage_C_10001.cs
  10. 1 1
      Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/InnerMessage_S_20001.cs
  11. 8 11
      Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/OuterMessage_C_10001.cs
  12. 1 1
      Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/InnerMessage_S_20001.cs
  13. 8 11
      Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/OuterMessage_C_10001.cs
  14. 2 2
      Unity/Assets/Scripts/Codes/Model/Share/Entry.cs
  15. 5 5
      Unity/Assets/Scripts/Codes/ModelView/Client/Demo/Config/ConfigLoader.cs
  16. 0 25
      Unity/Assets/Scripts/Core/Helper/JsonHelper.cs
  17. 0 20
      Unity/Assets/Scripts/Core/Helper/ProtobufRegister.cs
  18. 0 11
      Unity/Assets/Scripts/Core/Helper/ProtobufRegister.cs.meta
  19. 11 19
      Unity/Assets/Scripts/Core/Module/Config/ConfigComponent.cs
  20. 2 2
      Unity/Assets/Scripts/Core/Module/Network/KChannel.cs
  21. 1 1
      Unity/Assets/Scripts/Core/Module/Network/MessageSerializeHelper.cs
  22. 2 2
      Unity/Assets/Scripts/Core/Module/Network/TChannel.cs
  23. 2 2
      Unity/Assets/Scripts/Core/Module/Network/WChannel.cs
  24. 0 119
      Unity/Assets/Scripts/Core/Mongo/MongoHelper.cs
  25. 0 44
      Unity/Assets/Scripts/Core/Mongo/MongoRegister.cs
  26. 0 73
      Unity/Assets/Scripts/Core/Mongo/StructBsonSerialize.cs
  27. 0 11
      Unity/Assets/Scripts/Core/Mongo/StructBsonSerialize.cs.meta
  28. 2 2
      Unity/Assets/Scripts/Core/Object/ProtoObject.cs
  29. 8 0
      Unity/Assets/Scripts/Core/Serialize.meta
  30. 22 0
      Unity/Assets/Scripts/Core/Serialize/JsonHelper.cs
  31. 1 1
      Unity/Assets/Scripts/Core/Serialize/JsonHelper.cs.meta
  32. 230 0
      Unity/Assets/Scripts/Core/Serialize/MongoHelper.cs
  33. 0 0
      Unity/Assets/Scripts/Core/Serialize/MongoHelper.cs.meta
  34. 19 5
      Unity/Assets/Scripts/Core/Serialize/ProtobufHelper.cs
  35. 1 1
      Unity/Assets/Scripts/Core/Serialize/ProtobufHelper.cs.meta
  36. 28 0
      Unity/Assets/Scripts/Core/Serialize/SerializeHelper.cs
  37. 1 1
      Unity/Assets/Scripts/Core/Serialize/SerializeHelper.cs.meta
  38. 8 0
      Unity/Assets/Scripts/Core/Serializer.meta
  39. 5 0
      Unity/Assets/Scripts/Mono/CodeLoader.cs

+ 5 - 5
DotNet/App/ConfigLoader.cs

@@ -2,14 +2,14 @@ using System;
 using System.Collections.Generic;
 using System.IO;
 
-namespace ET
+namespace ET.Server
 {
     [Invoke]
-    public class GetAllConfigBytes: AInvokeHandler<ConfigComponent.GetAllConfigBytes, Dictionary<string, byte[]>>
+    public class GetAllConfigBytes: AInvokeHandler<ConfigComponent.GetAllConfigBytes, Dictionary<Type, byte[]>>
     {
-        public override Dictionary<string, byte[]> Handle(ConfigComponent.GetAllConfigBytes args)
+        public override Dictionary<Type, byte[]> Handle(ConfigComponent.GetAllConfigBytes args)
         {
-            Dictionary<string, byte[]> output = new Dictionary<string, byte[]>();
+            Dictionary<Type, byte[]> output = new Dictionary<Type, byte[]>();
             List<string> startConfigs = new List<string>()
             {
                 "StartMachineConfigCategory", 
@@ -29,7 +29,7 @@ namespace ET
                 {
                     configFilePath = $"../Config/Excel/s/{configType.Name}.bytes";
                 }
-                output[configType.Name] = File.ReadAllBytes(configFilePath);
+                output[configType] = File.ReadAllBytes(configFilePath);
             }
 
             return output;

+ 1 - 3
DotNet/App/ReloadDllConsoleHandler.cs

@@ -1,6 +1,4 @@
-using ET.Server;
-
-namespace ET
+namespace ET.Server
 {
     [ConsoleHandler(ConsoleMode.ReloadDll)]
     public class ReloadDllConsoleHandler: IConsoleHandler

+ 2 - 1
Share/Tool/Init.cs

@@ -36,7 +36,8 @@ namespace ET.Server
                 Dictionary<string, Type> types = AssemblyHelper.GetAssemblyTypes(typeof (Game).Assembly);
                 EventSystem.Instance.Add(types);
 
-                MongoRegister.Init();
+                MongoHelper.Init();
+                ProtobufHelper.Init();
 				
                 Log.Info($"server start........................ {Root.Instance.Scene.Id}");
 				

+ 24 - 2
Share/Tool/Proto2CS/Proto2CS.cs

@@ -159,7 +159,11 @@ namespace ET
 
                     if (newline.Trim() != "" && newline != "}")
                     {
-                        if (newline.StartsWith("repeated"))
+                        if (newline.StartsWith("map<"))
+                        {
+                            Map(sb, ns, newline);
+                        }
+                        else if (newline.StartsWith("repeated"))
                         {
                             Repeated(sb, ns, newline);
                         }
@@ -209,6 +213,24 @@ namespace ET
             using StreamWriter sw = new StreamWriter(txt);
             sw.Write(sb.ToString());
         }
+
+        private static void Map(StringBuilder sb, string ns, string newline)
+        {
+            int start = newline.IndexOf("<") + 1;
+            int end = newline.IndexOf(">");
+            string types = newline.Substring(start, end - start);
+            string[] ss = types.Split(",");
+            string keyType = ConvertType(ss[0].Trim());
+            string valueType = ConvertType(ss[1].Trim());
+            string tail = newline.Substring(end + 1);
+            ss = tail.Trim().Replace(";", "").Split(" ");
+            string v = ss[0];
+            string n = ss[2];
+            
+            sb.Append("\t\t[MongoDB.Bson.Serialization.Attributes.BsonDictionaryOptions(MongoDB.Bson.Serialization.Options.DictionaryRepresentation.ArrayOfArrays)]\n");
+            sb.Append($"\t\t[ProtoMember({n})]\n");
+            sb.Append($"\t\tpublic Dictionary<{keyType}, {valueType}> {v} {{ get; set; }}\n");
+        }
         
         private static void Repeated(StringBuilder sb, string ns, string newline)
         {
@@ -223,7 +245,7 @@ namespace ET
                 int n = int.Parse(ss[4]);
 
                 sb.Append($"\t\t[ProtoMember({n})]\n");
-                sb.Append($"\t\tpublic List<{type}> {name};\n\n");
+                sb.Append($"\t\tpublic List<{type}> {name} {{ get; set; }}\n\n");
             }
             catch (Exception e)
             {

+ 2 - 3
Unity/Assets/Config/Proto/OuterMessage_C_10001.proto

@@ -71,9 +71,8 @@ message UnitInfo
 	int32 Type = 3;
 	Unity.Mathematics.float3 Position = 4;
 	Unity.Mathematics.float3 Forward = 5;
-	repeated int32 Ks = 6;
-	repeated int64 Vs = 7;
-	MoveInfo MoveInfo = 8;
+	map<int32, int64> KV = 6;
+	MoveInfo MoveInfo = 7;
 }
 
 message M2C_CreateUnits // IActorMessage

+ 5 - 4
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Unit/UnitFactory.cs

@@ -14,10 +14,11 @@ namespace ET.Client
 	        unit.Forward = unitInfo.Forward;
 	        
 	        NumericComponent numericComponent = unit.AddComponent<NumericComponent>();
-	        for (int i = 0; i < unitInfo.Ks.Count; ++i)
-	        {
-		        numericComponent.Set(unitInfo.Ks[i], unitInfo.Vs[i]);
-	        }
+
+			foreach (var kv in unitInfo.KV)
+			{
+				numericComponent.Set(kv.Key, kv.Value);
+			}
 	        
 	        unit.AddComponent<MoveComponent>();
 	        if (unitInfo.MoveInfo != null)

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs

@@ -11,14 +11,14 @@ namespace ET.Server
 			reply();
 			
 			UnitComponent unitComponent = scene.GetComponent<UnitComponent>();
-			Unit unit = MongoHelper.FromBson<Unit>(request.Unit);
+			Unit unit = MongoHelper.Deserialize<Unit>(request.Unit);
 			
 			unitComponent.AddChild(unit);
 			unitComponent.Add(unit);
 
 			foreach (byte[] bytes in request.Entitys)
 			{
-				Entity entity = MongoHelper.FromBson<Entity>(bytes);
+				Entity entity = MongoHelper.Deserialize<Entity>(bytes);
 				unit.AddComponent(entity);
 			}
 			

+ 2 - 4
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit/UnitHelper.cs

@@ -32,13 +32,11 @@ namespace ET.Server
                 }
             }
 
-            unitInfo.Ks = new List<int>();
-            unitInfo.Vs = new List<long>();
+            unitInfo.KV = new Dictionary<int, long>();
 
             foreach ((int key, long value) in nc.NumericDic)
             {
-                unitInfo.Ks.Add(key);
-                unitInfo.Vs.Add(value);
+                unitInfo.KV.Add(key, value);
             }
 
             return unitInfo;

+ 8 - 11
Unity/Assets/Scripts/Codes/Model/Generate/Client/Message/OuterMessage_C_10001.cs

@@ -8,10 +8,10 @@ namespace ET
 	public partial class HttpGetRouterResponse: ProtoObject
 	{
 		[ProtoMember(1)]
-		public List<string> Realms;
+		public List<string> Realms { get; set; }
 
 		[ProtoMember(2)]
-		public List<string> Routers;
+		public List<string> Routers { get; set; }
 
 	}
 
@@ -120,7 +120,7 @@ namespace ET
 	public partial class MoveInfo: ProtoObject
 	{
 		[ProtoMember(1)]
-		public List<Unity.Mathematics.float3> Points;
+		public List<Unity.Mathematics.float3> Points { get; set; }
 
 		[ProtoMember(2)]
 		public Unity.Mathematics.quaternion Rotation { get; set; }
@@ -149,13 +149,10 @@ namespace ET
 		[ProtoMember(5)]
 		public Unity.Mathematics.float3 Forward { get; set; }
 
+		[MongoDB.Bson.Serialization.Attributes.BsonDictionaryOptions(MongoDB.Bson.Serialization.Options.DictionaryRepresentation.ArrayOfArrays)]
 		[ProtoMember(6)]
-		public List<int> Ks;
-
+		public Dictionary<int, long> KV { get; set; }
 		[ProtoMember(7)]
-		public List<long> Vs;
-
-		[ProtoMember(8)]
 		public MoveInfo MoveInfo { get; set; }
 
 	}
@@ -165,7 +162,7 @@ namespace ET
 	public partial class M2C_CreateUnits: ProtoObject, IActorMessage
 	{
 		[ProtoMember(1)]
-		public List<UnitInfo> Units;
+		public List<UnitInfo> Units { get; set; }
 
 	}
 
@@ -195,7 +192,7 @@ namespace ET
 	public partial class M2C_RemoveUnits: ProtoObject, IActorMessage
 	{
 		[ProtoMember(2)]
-		public List<long> Units;
+		public List<long> Units { get; set; }
 
 	}
 
@@ -231,7 +228,7 @@ namespace ET
 		public Unity.Mathematics.float3 Position { get; set; }
 
 		[ProtoMember(3)]
-		public List<Unity.Mathematics.float3> Points;
+		public List<Unity.Mathematics.float3> Points { get; set; }
 
 	}
 

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/InnerMessage_S_20001.cs

@@ -341,7 +341,7 @@ namespace ET
 		public byte[] Unit { get; set; }
 
 		[ProtoMember(4)]
-		public List<byte[]> Entitys;
+		public List<byte[]> Entitys { get; set; }
 
 	}
 

+ 8 - 11
Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/OuterMessage_C_10001.cs

@@ -8,10 +8,10 @@ namespace ET
 	public partial class HttpGetRouterResponse: ProtoObject
 	{
 		[ProtoMember(1)]
-		public List<string> Realms;
+		public List<string> Realms { get; set; }
 
 		[ProtoMember(2)]
-		public List<string> Routers;
+		public List<string> Routers { get; set; }
 
 	}
 
@@ -120,7 +120,7 @@ namespace ET
 	public partial class MoveInfo: ProtoObject
 	{
 		[ProtoMember(1)]
-		public List<Unity.Mathematics.float3> Points;
+		public List<Unity.Mathematics.float3> Points { get; set; }
 
 		[ProtoMember(2)]
 		public Unity.Mathematics.quaternion Rotation { get; set; }
@@ -149,13 +149,10 @@ namespace ET
 		[ProtoMember(5)]
 		public Unity.Mathematics.float3 Forward { get; set; }
 
+		[MongoDB.Bson.Serialization.Attributes.BsonDictionaryOptions(MongoDB.Bson.Serialization.Options.DictionaryRepresentation.ArrayOfArrays)]
 		[ProtoMember(6)]
-		public List<int> Ks;
-
+		public Dictionary<int, long> KV { get; set; }
 		[ProtoMember(7)]
-		public List<long> Vs;
-
-		[ProtoMember(8)]
 		public MoveInfo MoveInfo { get; set; }
 
 	}
@@ -165,7 +162,7 @@ namespace ET
 	public partial class M2C_CreateUnits: ProtoObject, IActorMessage
 	{
 		[ProtoMember(1)]
-		public List<UnitInfo> Units;
+		public List<UnitInfo> Units { get; set; }
 
 	}
 
@@ -195,7 +192,7 @@ namespace ET
 	public partial class M2C_RemoveUnits: ProtoObject, IActorMessage
 	{
 		[ProtoMember(2)]
-		public List<long> Units;
+		public List<long> Units { get; set; }
 
 	}
 
@@ -231,7 +228,7 @@ namespace ET
 		public Unity.Mathematics.float3 Position { get; set; }
 
 		[ProtoMember(3)]
-		public List<Unity.Mathematics.float3> Points;
+		public List<Unity.Mathematics.float3> Points { get; set; }
 
 	}
 

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/InnerMessage_S_20001.cs

@@ -341,7 +341,7 @@ namespace ET
 		public byte[] Unit { get; set; }
 
 		[ProtoMember(4)]
-		public List<byte[]> Entitys;
+		public List<byte[]> Entitys { get; set; }
 
 	}
 

+ 8 - 11
Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/OuterMessage_C_10001.cs

@@ -8,10 +8,10 @@ namespace ET
 	public partial class HttpGetRouterResponse: ProtoObject
 	{
 		[ProtoMember(1)]
-		public List<string> Realms;
+		public List<string> Realms { get; set; }
 
 		[ProtoMember(2)]
-		public List<string> Routers;
+		public List<string> Routers { get; set; }
 
 	}
 
@@ -120,7 +120,7 @@ namespace ET
 	public partial class MoveInfo: ProtoObject
 	{
 		[ProtoMember(1)]
-		public List<Unity.Mathematics.float3> Points;
+		public List<Unity.Mathematics.float3> Points { get; set; }
 
 		[ProtoMember(2)]
 		public Unity.Mathematics.quaternion Rotation { get; set; }
@@ -149,13 +149,10 @@ namespace ET
 		[ProtoMember(5)]
 		public Unity.Mathematics.float3 Forward { get; set; }
 
+		[MongoDB.Bson.Serialization.Attributes.BsonDictionaryOptions(MongoDB.Bson.Serialization.Options.DictionaryRepresentation.ArrayOfArrays)]
 		[ProtoMember(6)]
-		public List<int> Ks;
-
+		public Dictionary<int, long> KV { get; set; }
 		[ProtoMember(7)]
-		public List<long> Vs;
-
-		[ProtoMember(8)]
 		public MoveInfo MoveInfo { get; set; }
 
 	}
@@ -165,7 +162,7 @@ namespace ET
 	public partial class M2C_CreateUnits: ProtoObject, IActorMessage
 	{
 		[ProtoMember(1)]
-		public List<UnitInfo> Units;
+		public List<UnitInfo> Units { get; set; }
 
 	}
 
@@ -195,7 +192,7 @@ namespace ET
 	public partial class M2C_RemoveUnits: ProtoObject, IActorMessage
 	{
 		[ProtoMember(2)]
-		public List<long> Units;
+		public List<long> Units { get; set; }
 
 	}
 
@@ -231,7 +228,7 @@ namespace ET
 		public Unity.Mathematics.float3 Position { get; set; }
 
 		[ProtoMember(3)]
-		public List<Unity.Mathematics.float3> Points;
+		public List<Unity.Mathematics.float3> Points { get; set; }
 
 	}
 

+ 2 - 2
Unity/Assets/Scripts/Codes/Model/Share/Entry.cs

@@ -26,8 +26,8 @@
         {
             WinPeriod.Init();
             
-            MongoRegister.Init();
-            ProtobufRegister.Init();
+            MongoHelper.Init();
+            ProtobufHelper.Init();
             
             Game.AddSingleton<NetServices>();
             Game.AddSingleton<Root>();

+ 5 - 5
Unity/Assets/Scripts/Codes/ModelView/Client/Demo/Config/ConfigLoader.cs

@@ -6,11 +6,11 @@ using UnityEngine;
 namespace ET.Client
 {
     [Invoke]
-    public class GetAllConfigBytes: AInvokeHandler<ConfigComponent.GetAllConfigBytes, Dictionary<string, byte[]>>
+    public class GetAllConfigBytes: AInvokeHandler<ConfigComponent.GetAllConfigBytes, Dictionary<Type, byte[]>>
     {
-        public override Dictionary<string, byte[]> Handle(ConfigComponent.GetAllConfigBytes args)
+        public override Dictionary<Type, byte[]> Handle(ConfigComponent.GetAllConfigBytes args)
         {
-            Dictionary<string, byte[]> output = new Dictionary<string, byte[]>();
+            Dictionary<Type, byte[]> output = new Dictionary<Type, byte[]>();
             HashSet<Type> configTypes = EventSystem.Instance.GetTypes(typeof (ConfigAttribute));
             
             if (Define.IsEditor)
@@ -49,7 +49,7 @@ namespace ET.Client
                     {
                         configFilePath = $"../Config/Excel/{ct}/{configType.Name}.bytes";
                     }
-                    output[configType.Name] = File.ReadAllBytes(configFilePath);
+                    output[configType] = File.ReadAllBytes(configFilePath);
                 }
             }
             else
@@ -62,7 +62,7 @@ namespace ET.Client
                     foreach (Type configType in configTypes)
                     {
                         TextAsset v = ResourcesComponent.Instance.GetAsset(configBundleName, configType.Name) as TextAsset;
-                        output[configType.Name] = v.bytes;
+                        output[configType] = v.bytes;
                     }
                 }
             }

+ 0 - 25
Unity/Assets/Scripts/Core/Helper/JsonHelper.cs

@@ -1,25 +0,0 @@
-using System;
-
-namespace ET
-{
-    public static class JsonHelper
-    {
-        [StaticField]
-        private static readonly MongoDB.Bson.IO.JsonWriterSettings logDefineSettings = new MongoDB.Bson.IO.JsonWriterSettings() { OutputMode = MongoDB.Bson.IO.JsonOutputMode.RelaxedExtendedJson };
-        
-        public static string ToJson(object message)
-        {
-            return MongoDB.Bson.BsonExtensionMethods.ToJson(message, logDefineSettings);
-        }
-        
-        public static object FromJson(Type type, string json)
-        {
-            return MongoDB.Bson.Serialization.BsonSerializer.Deserialize(json, type);
-        }
-        
-        public static T FromJson<T>(string json)
-        {
-            return MongoDB.Bson.Serialization.BsonSerializer.Deserialize<T>(json);
-        }
-    }
-}

+ 0 - 20
Unity/Assets/Scripts/Core/Helper/ProtobufRegister.cs

@@ -1,20 +0,0 @@
-using ProtoBuf.Meta;
-using Unity.Mathematics;
-
-namespace ET
-{
-    public static class ProtobufRegister
-    {
-        public static void Init()
-        {
-        }
-        
-        static ProtobufRegister()
-        {
-            RuntimeTypeModel.Default.Add(typeof(float2), false).Add("x", "y");
-            RuntimeTypeModel.Default.Add(typeof(float3), false).Add("x", "y", "z");
-            RuntimeTypeModel.Default.Add(typeof(float4), false).Add("x", "y", "z", "w");
-            RuntimeTypeModel.Default.Add(typeof(quaternion), false).Add("value");
-        }
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Core/Helper/ProtobufRegister.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 691f568543138f947958d41bc561df39
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 11 - 19
Unity/Assets/Scripts/Core/Module/Config/ConfigComponent.cs

@@ -38,7 +38,7 @@ namespace ET
 			
 			byte[] oneConfigBytes = EventSystem.Instance.Invoke<GetOneConfigBytes, byte[]>(0, new GetOneConfigBytes() {ConfigName = configType.FullName});
 
-			object category = SerializerHelper.FromBytes(configType, oneConfigBytes, 0, oneConfigBytes.Length);
+			object category = SerializeHelper.Deserialize(configType, oneConfigBytes, 0, oneConfigBytes.Length);
 			ISingleton singleton = category as ISingleton;
 			singleton.Register();
 			
@@ -49,32 +49,26 @@ namespace ET
 		public void Load()
 		{
 			this.allConfig.Clear();
-			HashSet<Type> types = EventSystem.Instance.GetTypes(typeof (ConfigAttribute));
-			
-			Dictionary<string, byte[]> configBytes = 
-			EventSystem.Instance.Invoke<GetAllConfigBytes, Dictionary<string, byte[]>>(0, 
-				new GetAllConfigBytes());
+			Dictionary<Type, byte[]> configBytes = EventSystem.Instance.Invoke<GetAllConfigBytes, Dictionary<Type, byte[]>>(0, new GetAllConfigBytes());
 
-			foreach (Type type in types)
+			foreach (Type type in configBytes.Keys)
 			{
-				this.LoadOneInThread(type, configBytes);
+				byte[] oneConfigBytes = configBytes[type];
+				this.LoadOneInThread(type, oneConfigBytes);
 			}
 		}
 		
 		public async ETTask LoadAsync()
 		{
 			this.allConfig.Clear();
-			HashSet<Type> types = EventSystem.Instance.GetTypes(typeof (ConfigAttribute));
-			
-			Dictionary<string, byte[]> configBytes = 
-					EventSystem.Instance.Invoke<GetAllConfigBytes, Dictionary<string, byte[]>>(0,
-						new GetAllConfigBytes());
+			Dictionary<Type, byte[]> configBytes = EventSystem.Instance.Invoke<GetAllConfigBytes, Dictionary<Type, byte[]>>(0, new GetAllConfigBytes());
 
 			using ListComponent<Task> listTasks = ListComponent<Task>.Create();
 			
-			foreach (Type type in types)
+			foreach (Type type in configBytes.Keys)
 			{
-				Task task = Task.Run(() => LoadOneInThread(type, configBytes));
+				byte[] oneConfigBytes = configBytes[type];
+				Task task = Task.Run(() => LoadOneInThread(type, oneConfigBytes));
 				listTasks.Add(task);
 			}
 
@@ -86,11 +80,9 @@ namespace ET
 			}
 		}
 		
-		private void LoadOneInThread(Type configType, Dictionary<string, byte[]> configBytes)
+		private void LoadOneInThread(Type configType, byte[] oneConfigBytes)
 		{
-			byte[] oneConfigBytes = configBytes[configType.Name];
-
-			object category = SerializerHelper.FromBytes(configType, oneConfigBytes, 0, oneConfigBytes.Length);
+			object category = SerializeHelper.Deserialize(configType, oneConfigBytes, 0, oneConfigBytes.Length);
 			
 			lock (this)
 			{

+ 2 - 2
Unity/Assets/Scripts/Core/Module/Network/KChannel.cs

@@ -485,7 +485,7 @@ namespace ET
 					{
 						ushort opcode = BitConverter.ToUInt16(memoryStream.GetBuffer(), Packet.KcpOpcodeIndex);
 						Type type = NetServices.Instance.GetType(opcode);
-						message = SerializerHelper.FromStream(type, memoryStream);
+						message = SerializeHelper.Deserialize(type, memoryStream);
 						break;
 					}
 					case ServiceType.Inner:
@@ -493,7 +493,7 @@ namespace ET
 						actorId = BitConverter.ToInt64(memoryStream.GetBuffer(), Packet.ActorIdIndex);
 						ushort opcode = BitConverter.ToUInt16(memoryStream.GetBuffer(), Packet.OpcodeIndex);
 						Type type = NetServices.Instance.GetType(opcode);
-						message = SerializerHelper.FromStream(type, memoryStream);
+						message = SerializeHelper.Deserialize(type, memoryStream);
 						break;
 					}
 				}

+ 1 - 1
Unity/Assets/Scripts/Core/Module/Network/MessageSerializeHelper.cs

@@ -32,7 +32,7 @@ namespace ET
             
             stream.GetBuffer().WriteTo(headOffset, opcode);
             
-            SerializerHelper.ToStream(message, stream);
+            SerializeHelper.Serialize(message, stream);
             
             stream.Seek(0, SeekOrigin.Begin);
             return (opcode, stream);

+ 2 - 2
Unity/Assets/Scripts/Core/Module/Network/TChannel.cs

@@ -365,7 +365,7 @@ namespace ET
 					{
 						ushort opcode = BitConverter.ToUInt16(memoryStream.GetBuffer(), Packet.KcpOpcodeIndex);
 						Type type = NetServices.Instance.GetType(opcode);
-						message = SerializerHelper.FromStream(type, memoryStream);
+						message = SerializeHelper.Deserialize(type, memoryStream);
 						break;
 					}
 					case ServiceType.Inner:
@@ -373,7 +373,7 @@ namespace ET
 						actorId = BitConverter.ToInt64(memoryStream.GetBuffer(), Packet.ActorIdIndex);
 						ushort opcode = BitConverter.ToUInt16(memoryStream.GetBuffer(), Packet.OpcodeIndex);
 						Type type = NetServices.Instance.GetType(opcode);
-						message = SerializerHelper.FromStream(type, memoryStream);
+						message = SerializeHelper.Deserialize(type, memoryStream);
 						break;
 					}
 				}

+ 2 - 2
Unity/Assets/Scripts/Core/Module/Network/WChannel.cs

@@ -221,7 +221,7 @@ namespace ET
                     {
                         ushort opcode = BitConverter.ToUInt16(memoryStream.GetBuffer(), Packet.KcpOpcodeIndex);
                         Type type = NetServices.Instance.GetType(opcode);
-                        message = SerializerHelper.FromStream(type, memoryStream);
+                        message = SerializeHelper.Deserialize(type, memoryStream);
                         break;
                     }
                     case ServiceType.Inner:
@@ -229,7 +229,7 @@ namespace ET
                         actorId = BitConverter.ToInt64(memoryStream.GetBuffer(), Packet.ActorIdIndex);
                         ushort opcode = BitConverter.ToUInt16(memoryStream.GetBuffer(), Packet.OpcodeIndex);
                         Type type = NetServices.Instance.GetType(opcode);
-                        message = SerializerHelper.FromStream(type, memoryStream);
+                        message = SerializeHelper.Deserialize(type, memoryStream);
                         break;
                     }
                 }

+ 0 - 119
Unity/Assets/Scripts/Core/Mongo/MongoHelper.cs

@@ -1,119 +0,0 @@
-using System;
-using System.IO;
-using MongoDB.Bson;
-using MongoDB.Bson.IO;
-using MongoDB.Bson.Serialization;
-
-namespace ET
-{
-    public static class MongoHelper
-    {
-        public static string ToJson(object obj)
-        {
-            return obj.ToJson();
-        }
-
-        public static string ToJson(object obj, JsonWriterSettings settings)
-        {
-            return obj.ToJson(settings);
-        }
-
-        public static T FromJson<T>(string str)
-        {
-            try
-            {
-                return BsonSerializer.Deserialize<T>(str);
-            }
-            catch (Exception e)
-            {
-                throw new Exception($"{str}\n{e}");
-            }
-        }
-
-        public static object FromJson(Type type, string str)
-        {
-            return BsonSerializer.Deserialize(str, type);
-        }
-
-        public static byte[] ToBson(object obj)
-        {
-            return obj.ToBson();
-        }
-
-        public static void ToStream(object message, MemoryStream stream)
-        {
-            using (BsonBinaryWriter bsonWriter = new BsonBinaryWriter(stream, BsonBinaryWriterSettings.Defaults))
-            {
-                BsonSerializationContext context = BsonSerializationContext.CreateRoot(bsonWriter);
-                BsonSerializationArgs args = default;
-                args.NominalType = typeof (object);
-                IBsonSerializer serializer = BsonSerializer.LookupSerializer(args.NominalType);
-                serializer.Serialize(context, args, message);
-            }
-        }
-
-        public static object FromBson(Type type, byte[] bytes)
-        {
-            try
-            {
-                return BsonSerializer.Deserialize(bytes, type);
-            }
-            catch (Exception e)
-            {
-                throw new Exception($"from bson error: {type.Name}", e);
-            }
-        }
-
-        public static object FromBson(Type type, byte[] bytes, int index, int count)
-        {
-            try
-            {
-                using (MemoryStream memoryStream = new MemoryStream(bytes, index, count))
-                {
-                    return BsonSerializer.Deserialize(memoryStream, type);
-                }
-            }
-            catch (Exception e)
-            {
-                throw new Exception($"from bson error: {type.Name}", e);
-            }
-        }
-
-        public static object FromStream(Type type, Stream stream)
-        {
-            try
-            {
-                return BsonSerializer.Deserialize(stream, type);
-            }
-            catch (Exception e)
-            {
-                throw new Exception($"from bson error: {type.Name}", e);
-            }
-        }
-
-        public static T FromBson<T>(byte[] bytes)
-        {
-            try
-            {
-                using (MemoryStream memoryStream = new MemoryStream(bytes))
-                {
-                    return (T) BsonSerializer.Deserialize(memoryStream, typeof (T));
-                }
-            }
-            catch (Exception e)
-            {
-                throw new Exception($"from bson error: {typeof (T).Name}", e);
-            }
-        }
-
-        public static T FromBson<T>(byte[] bytes, int index, int count)
-        {
-            return (T) FromBson(typeof (T), bytes, index, count);
-        }
-
-        public static T Clone<T>(T t)
-        {
-            return FromBson<T>(ToBson(t));
-        }
-    }
-}

+ 0 - 44
Unity/Assets/Scripts/Core/Mongo/MongoRegister.cs

@@ -1,44 +0,0 @@
-using System;
-using System.Collections.Generic;
-using MongoDB.Bson.Serialization;
-using MongoDB.Bson.Serialization.Conventions;
-using Unity.Mathematics;
-
-namespace ET
-{
-    public static class MongoRegister
-    {
-        public static void Init()
-        {
-        }
-        
-        static MongoRegister()
-        {
-            // 自动注册IgnoreExtraElements
-
-            ConventionPack conventionPack = new ConventionPack { new IgnoreExtraElementsConvention(true) };
-
-            ConventionRegistry.Register("IgnoreExtraElements", conventionPack, type => true);
-
-            BsonSerializer.RegisterSerializer(typeof(float3), new StructBsonSerialize<float3>());
-            BsonSerializer.RegisterSerializer(typeof(float4), new StructBsonSerialize<float4>());
-            BsonSerializer.RegisterSerializer(typeof(quaternion), new StructBsonSerialize<quaternion>());
-
-            Dictionary<string, Type> types = EventSystem.Instance.GetTypes();
-            foreach (Type type in types.Values)
-            {
-                if (!type.IsSubclassOf(typeof (Object)))
-                {
-                    continue;
-                }
-
-                if (type.IsGenericType)
-                {
-                    continue;
-                }
-
-                BsonClassMap.LookupClassMap(type);
-            }
-        }
-    }
-}

+ 0 - 73
Unity/Assets/Scripts/Core/Mongo/StructBsonSerialize.cs

@@ -1,73 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using MongoDB.Bson;
-using MongoDB.Bson.IO;
-using MongoDB.Bson.Serialization;
-using MongoDB.Bson.Serialization.Serializers;
-
-namespace ET
-{
-    public class StructBsonSerialize<TValue>: StructSerializerBase<TValue> where TValue : struct
-    {
-        public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, TValue value)
-        {
-            Type nominalType = args.NominalType;
-
-            IBsonWriter bsonWriter = context.Writer;
-
-            bsonWriter.WriteStartDocument();
-
-            FieldInfo[] fields = nominalType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
-            foreach (FieldInfo field in fields)
-            {
-                bsonWriter.WriteName(field.Name);
-                BsonSerializer.Serialize(bsonWriter, field.FieldType, field.GetValue(value));
-            }
-
-            bsonWriter.WriteEndDocument();
-        }
-
-        public override TValue Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
-        {
-            //boxing is required for SetValue to work
-            object obj = new TValue();
-            Type actualType = args.NominalType;
-            IBsonReader bsonReader = context.Reader;
-
-            bsonReader.ReadStartDocument();
-
-            while (bsonReader.State != BsonReaderState.EndOfDocument)
-            {
-                switch (bsonReader.State)
-                {
-                    case BsonReaderState.Name:
-                    {
-                        string name = bsonReader.ReadName(Utf8NameDecoder.Instance);
-                        FieldInfo field = actualType.GetField(name);
-                        if (field != null)
-                        {
-                            object value = BsonSerializer.Deserialize(bsonReader, field.FieldType);
-                            field.SetValue(obj, value);
-                        }
-                        break;
-                    }
-                    case BsonReaderState.Type:
-                    {
-                        bsonReader.ReadBsonType();
-                        break;
-                    }
-                    case BsonReaderState.Value:
-                    {
-                        bsonReader.SkipValue();
-                        break;
-                    }
-                }
-            }
-
-            bsonReader.ReadEndDocument();
-
-            return (TValue) obj;
-        }
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Core/Mongo/StructBsonSerialize.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 2a787fb9606a09f4588f3feed82c5377
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 2 - 2
Unity/Assets/Scripts/Core/Object/ProtoObject.cs

@@ -7,8 +7,8 @@ namespace ET
     {
         public object Clone()
         {
-            byte[] bytes = SerializerHelper.ToBytes(this);
-            return SerializerHelper.FromBytes(this.GetType(), bytes, 0, bytes.Length);
+            byte[] bytes = SerializeHelper.Serialize(this);
+            return SerializeHelper.Deserialize(this.GetType(), bytes, 0, bytes.Length);
         }
         
         public virtual void BeginInit()

+ 8 - 0
Unity/Assets/Scripts/Core/Serialize.meta

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

+ 22 - 0
Unity/Assets/Scripts/Core/Serialize/JsonHelper.cs

@@ -0,0 +1,22 @@
+using System;
+
+namespace ET
+{
+    public static class JsonHelper
+    {
+        public static string ToJson(object o)
+        {
+            return MongoHelper.ToJson(o);
+        }
+        
+        public static object FromJson(Type type, string json)
+        {
+            return MongoHelper.FromJson(type, json);
+        }
+        
+        public static T FromJson<T>(string json)
+        {
+            return MongoHelper.FromJson<T>(json);
+        }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Core/Helper/JsonHelper.cs.meta → Unity/Assets/Scripts/Core/Serialize/JsonHelper.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 2fd0119d404d61748a0f289373495b47
+guid: 3705e695c7ffb584b9d977fe2fae73ad
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 230 - 0
Unity/Assets/Scripts/Core/Serialize/MongoHelper.cs

@@ -0,0 +1,230 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using MongoDB.Bson;
+using MongoDB.Bson.IO;
+using MongoDB.Bson.Serialization;
+using MongoDB.Bson.Serialization.Conventions;
+using MongoDB.Bson.Serialization.Serializers;
+using Unity.Mathematics;
+
+namespace ET
+{
+    public static class MongoHelper
+    {
+        private class StructBsonSerialize<TValue>: StructSerializerBase<TValue> where TValue : struct
+        {
+            public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, TValue value)
+            {
+                Type nominalType = args.NominalType;
+
+                IBsonWriter bsonWriter = context.Writer;
+
+                bsonWriter.WriteStartDocument();
+
+                FieldInfo[] fields = nominalType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+                foreach (FieldInfo field in fields)
+                {
+                    bsonWriter.WriteName(field.Name);
+                    BsonSerializer.Serialize(bsonWriter, field.FieldType, field.GetValue(value));
+                }
+
+                bsonWriter.WriteEndDocument();
+            }
+
+            public override TValue Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
+            {
+                //boxing is required for SetValue to work
+                object obj = new TValue();
+                Type actualType = args.NominalType;
+                IBsonReader bsonReader = context.Reader;
+
+                bsonReader.ReadStartDocument();
+
+                while (bsonReader.State != BsonReaderState.EndOfDocument)
+                {
+                    switch (bsonReader.State)
+                    {
+                        case BsonReaderState.Name:
+                        {
+                            string name = bsonReader.ReadName(Utf8NameDecoder.Instance);
+                            FieldInfo field = actualType.GetField(name);
+                            if (field != null)
+                            {
+                                object value = BsonSerializer.Deserialize(bsonReader, field.FieldType);
+                                field.SetValue(obj, value);
+                            }
+
+                            break;
+                        }
+                        case BsonReaderState.Type:
+                        {
+                            bsonReader.ReadBsonType();
+                            break;
+                        }
+                        case BsonReaderState.Value:
+                        {
+                            bsonReader.SkipValue();
+                            break;
+                        }
+                    }
+                }
+
+                bsonReader.ReadEndDocument();
+
+                return (TValue)obj;
+            }
+        }
+
+        [StaticField]
+        private static readonly JsonWriterSettings defaultSettings = new() { OutputMode = JsonOutputMode.RelaxedExtendedJson };
+
+        static MongoHelper()
+        {
+            // 自动注册IgnoreExtraElements
+
+            ConventionPack conventionPack = new ConventionPack { new IgnoreExtraElementsConvention(true) };
+
+            ConventionRegistry.Register("IgnoreExtraElements", conventionPack, type => true);
+
+            RegisterStruct<float2>();
+            RegisterStruct<float3>();
+            RegisterStruct<float4>();
+            RegisterStruct<quaternion>();
+
+            Dictionary<string, Type> types = EventSystem.Instance.GetTypes();
+            foreach (Type type in types.Values)
+            {
+                if (!type.IsSubclassOf(typeof (Object)))
+                {
+                    continue;
+                }
+
+                if (type.IsGenericType)
+                {
+                    continue;
+                }
+
+                BsonClassMap.LookupClassMap(type);
+            }
+        }
+
+        public static void Init()
+        {
+        }
+
+        public static void RegisterStruct<T>() where T : struct
+        {
+            BsonSerializer.RegisterSerializer(typeof (T), new StructBsonSerialize<T>());
+        }
+
+        public static string ToJson(object obj)
+        {
+            return obj.ToJson(defaultSettings);
+        }
+
+        public static string ToJson(object obj, JsonWriterSettings settings)
+        {
+            return obj.ToJson(settings);
+        }
+
+        public static T FromJson<T>(string str)
+        {
+            try
+            {
+                return BsonSerializer.Deserialize<T>(str);
+            }
+            catch (Exception e)
+            {
+                throw new Exception($"{str}\n{e}");
+            }
+        }
+
+        public static object FromJson(Type type, string str)
+        {
+            return BsonSerializer.Deserialize(str, type);
+        }
+
+        public static byte[] Serialize(object obj)
+        {
+            return obj.ToBson();
+        }
+
+        public static void Serialize(object message, MemoryStream stream)
+        {
+            using (BsonBinaryWriter bsonWriter = new BsonBinaryWriter(stream, BsonBinaryWriterSettings.Defaults))
+            {
+                BsonSerializationContext context = BsonSerializationContext.CreateRoot(bsonWriter);
+                BsonSerializationArgs args = default;
+                args.NominalType = typeof (object);
+                IBsonSerializer serializer = BsonSerializer.LookupSerializer(args.NominalType);
+                serializer.Serialize(context, args, message);
+            }
+        }
+
+        public static object Deserialize(Type type, byte[] bytes)
+        {
+            try
+            {
+                return BsonSerializer.Deserialize(bytes, type);
+            }
+            catch (Exception e)
+            {
+                throw new Exception($"from bson error: {type.Name}", e);
+            }
+        }
+
+        public static object Deserialize(Type type, byte[] bytes, int index, int count)
+        {
+            try
+            {
+                using (MemoryStream memoryStream = new MemoryStream(bytes, index, count))
+                {
+                    return BsonSerializer.Deserialize(memoryStream, type);
+                }
+            }
+            catch (Exception e)
+            {
+                throw new Exception($"from bson error: {type.Name}", e);
+            }
+        }
+
+        public static object Deserialize(Type type, Stream stream)
+        {
+            try
+            {
+                return BsonSerializer.Deserialize(stream, type);
+            }
+            catch (Exception e)
+            {
+                throw new Exception($"from bson error: {type.Name}", e);
+            }
+        }
+
+        public static T Deserialize<T>(byte[] bytes)
+        {
+            try
+            {
+                using (MemoryStream memoryStream = new MemoryStream(bytes))
+                {
+                    return (T)BsonSerializer.Deserialize(memoryStream, typeof (T));
+                }
+            }
+            catch (Exception e)
+            {
+                throw new Exception($"from bson error: {typeof (T).Name}", e);
+            }
+        }
+
+        public static T Deserialize<T>(byte[] bytes, int index, int count)
+        {
+            return (T)Deserialize(typeof (T), bytes, index, count);
+        }
+
+        public static T Clone<T>(T t)
+        {
+            return Deserialize<T>(Serialize(t));
+        }
+    }
+}

+ 0 - 0
Unity/Assets/Scripts/Core/Mongo/MongoHelper.cs.meta → Unity/Assets/Scripts/Core/Serialize/MongoHelper.cs.meta


+ 19 - 5
Unity/Assets/Scripts/Core/Helper/SerializerHelper.cs → Unity/Assets/Scripts/Core/Serialize/ProtobufHelper.cs

@@ -1,12 +1,26 @@
 using System;
 using System.ComponentModel;
 using System.IO;
+using ProtoBuf.Meta;
+using Unity.Mathematics;
 
 namespace ET
 {
-    public static class SerializerHelper
+    public static class ProtobufHelper
     {
-		public static object FromBytes(Type type, byte[] bytes, int index, int count)
+		public static void Init()
+		{
+		}
+        
+		static ProtobufHelper()
+		{
+			RuntimeTypeModel.Default.Add(typeof(float2), false).Add("x", "y");
+			RuntimeTypeModel.Default.Add(typeof(float3), false).Add("x", "y", "z");
+			RuntimeTypeModel.Default.Add(typeof(float4), false).Add("x", "y", "z", "w");
+			RuntimeTypeModel.Default.Add(typeof(quaternion), false).Add("value");
+		}
+		
+		public static object Deserialize(Type type, byte[] bytes, int index, int count)
 		{
 			using MemoryStream stream = new MemoryStream(bytes, index, count);
 			object o = ProtoBuf.Serializer.Deserialize(type, stream);
@@ -17,19 +31,19 @@ namespace ET
 			return o;
 		}
 
-        public static byte[] ToBytes(object message)
+        public static byte[] Serialize(object message)
 		{
 			using MemoryStream stream = new MemoryStream();
 			ProtoBuf.Serializer.Serialize(stream, message);
 			return stream.ToArray();
 		}
 
-        public static void ToStream(object message, Stream stream)
+        public static void Serialize(object message, Stream stream)
         {
             ProtoBuf.Serializer.Serialize(stream, message);
         }
 
-        public static object FromStream(Type type, Stream stream)
+        public static object Deserialize(Type type, Stream stream)
         {
 	        object o = ProtoBuf.Serializer.Deserialize(type, stream);
 	        if (o is ISupportInitialize supportInitialize)

+ 1 - 1
Unity/Assets/Scripts/Core/Helper/SerializerHelper.cs.meta → Unity/Assets/Scripts/Core/Serialize/ProtobufHelper.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: a3b861f42265cab42b4ece0b6091e9da
+guid: 82016b7c3ac7f3945b1a7eb9d0f38fd8
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 28 - 0
Unity/Assets/Scripts/Core/Serialize/SerializeHelper.cs

@@ -0,0 +1,28 @@
+using System.IO;
+using System;
+
+namespace ET
+{
+    public static class SerializeHelper
+    {
+		public static object Deserialize(Type type, byte[] bytes, int index, int count)
+		{
+			return ProtobufHelper.Deserialize(type, bytes, index, count);
+		}
+
+        public static byte[] Serialize(object message)
+		{
+			return ProtobufHelper.Serialize(message);
+		}
+
+        public static void Serialize(object message, Stream stream)
+        {
+            ProtobufHelper.Serialize(message, stream);
+        }
+
+        public static object Deserialize(Type type, Stream stream)
+        {
+	        return ProtobufHelper.Deserialize(type, stream);
+        }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Core/Mongo/MongoRegister.cs.meta → Unity/Assets/Scripts/Core/Serialize/SerializeHelper.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 02070311587b87a498f3cd48344f7dbb
+guid: 94e49eb218611e847ac10578b1e66124
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 8 - 0
Unity/Assets/Scripts/Core/Serializer.meta

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

+ 5 - 0
Unity/Assets/Scripts/Mono/CodeLoader.cs

@@ -14,6 +14,11 @@ namespace ET
 		{
 			if (Define.EnableCodes)
 			{
+				if (Init.Instance.GlobalConfig.CodeMode != CodeMode.ClientServer)
+				{
+					throw new Exception("ENABLE_CODES mode must use ClientServer code mode!");
+				}
+				
 				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
 				Dictionary<string, Type> types = AssemblyHelper.GetAssemblyTypes(assemblies);
 				EventSystem.Instance.Add(types);