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

完善proto生成工具,增加生成InnerMessage.proto

tanghai 7 лет назад
Родитель
Сommit
ea931c3249

+ 110 - 37
Proto/InnerMessage.proto

@@ -3,176 +3,249 @@
 	/// </summary>
 	message M2M_TrasferUnitRequest // IRequest
 	{
-		required Unit Unit = 1;
+		int32 RpcId = 90;
+		Unit Unit = 1;
 	}
 	
 	message M2M_TrasferUnitResponse // IResponse
 	{
-		required int64 InstanceId = 1;
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
+
+		int64 InstanceId = 1;
 	}
 	
 	message M2A_Reload // IRequest
 	{
+		int32 RpcId = 90;
 	}
 
 	message A2M_Reload // IResponse
 	{
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
 	}
 
 	message G2G_LockRequest // IRequest
 	{
-		required int64 Id = 1;
-		required string Address = 2;
+		int32 RpcId = 90;
+		int64 Id = 1;
+		string Address = 2;
 	}
 
 	message G2G_LockResponse // IResponse
 	{
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
 	}
 
 	message G2G_LockReleaseRequest // IRequest
 	{
-		required int64 Id = 1;
-		required string Address = 2;
+		int32 RpcId = 90;
+		int64 Id = 1;
+		string Address = 2;
 	}
 
 	message G2G_LockReleaseResponse // IResponse
 	{
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
 	}
 
 	message DBSaveRequest // IRequest
 	{
-		required bool NeedCache = 1;
-
-		required string CollectionName = 2;
+		int32 RpcId = 90;
 
-		required ComponentWithId Component = 3;
+		bool NeedCache = 1;
+		string CollectionName = 2;
+		ComponentWithId Component = 3;
 	}
 
 
 	message DBSaveBatchResponse // IResponse
 	{
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
 	}
 
 	message DBSaveBatchRequest // IRequest
 	{
-		required bool NeedCache = 1;
-		required string CollectionName = 2;
+		int32 RpcId = 90;
+
+		bool NeedCache = 1;
+		string CollectionName = 2;
 		repeated ComponentWithId Components = 3;
 	}
 
 	message DBSaveResponse // IResponse
 	{
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
 	}
 
 	message DBQueryRequest // IRequest
 	{
-		required int64 Id = 1;
-		required string CollectionName = 2;
-		required bool NeedCache = 3;
+		int32 RpcId = 90;
+		int64 Id = 1;
+		string CollectionName = 2;
+		bool NeedCache = 3;
 	}
 
 	message DBQueryResponse // IResponse
 	{
-		required ComponentWithId Component = 1;
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
+
+		ComponentWithId Component = 1;
 	}
 
 	message DBQueryBatchRequest // IRequest
 	{
-		required string CollectionName = 1;
+		int32 RpcId = 90;
+		string CollectionName = 1;
 		repeated int64 IdList = 2;
-		required bool NeedCache = 3;
+		bool NeedCache = 3;
 	}
 
 	message DBQueryBatchResponse // IResponse
 	{
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
+
 		repeated ComponentWithId Components = 1;
 	}
 
 	message DBQueryJsonRequest // IRequest
 	{
-		required string CollectionName = 1;
-		required string Json = 2;
+		int32 RpcId = 90;
+		string CollectionName = 1;
+		string Json = 2;
 	}
 
 	message DBQueryJsonResponse // IResponse
 	{
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
+
 		repeated ComponentWithId Components = 1;
 	}
 
 	message ObjectAddRequest // IRequest
 	{
-		required int64 Key = 1;
-		required int64 InstanceId = 2;
+		int32 RpcId = 90;
+		int64 Key = 1;
+		int64 InstanceId = 2;
 	}
 
 	message ObjectAddResponse // IResponse
 	{
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
 	}
 
 	message ObjectRemoveRequest // IRequest
 	{
-		required int64 Key = 1;
+		int32 RpcId = 90;
+		int64 Key = 1;
 	}
 
 	message ObjectRemoveResponse // IResponse
 	{
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
 	}
 
 	message ObjectLockRequest // IRequest
 	{
-		required int64 Key = 1;
-		required int64 InstanceId = 2;
-		required int Time = 3;
+		int32 RpcId = 90;
+		int64 Key = 1;
+		int64 InstanceId = 2;
+		int Time = 3;
 	}
 
 	message ObjectLockResponse // IResponse
 	{
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
 	}
 
 	message ObjectUnLockRequest // IRequest
 	{
-		required int64 Key = 1;
-		required int64 OldInstanceId = 2;
-		required int64 InstanceId = 3;
+		int32 RpcId = 90;
+		int64 Key = 1;
+		int64 OldInstanceId = 2;
+		int64 InstanceId = 3;
 	}
 
 	message ObjectUnLockResponse // IResponse
 	{
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
 	}
 
 	message ObjectGetRequest // IRequest
 	{
-		required int64 Key = 1;
+		int32 RpcId = 90;
+		int64 Key = 1;
 	}
 
 	message ObjectGetResponse // IResponse
 	{
-		required int64 InstanceId = 1;
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
+
+		int64 InstanceId = 1;
 	}
 
 	message R2G_GetLoginKey // IRequest
 	{
-		required string Account = 1;
+		int32 RpcId = 90;
+		string Account = 1;
 	}
 
 	message G2R_GetLoginKey // IResponse
 	{
-		required int64 Key = 1;
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
+
+		int64 Key = 1;
 	}
 
 	message G2M_CreateUnit // IRequest
 	{
-		required int64 PlayerId = 1;
-		required int64 GateSessionId = 2;
+		int32 RpcId = 90;
+		int64 PlayerId = 1;
+		int64 GateSessionId = 2;
 	}
 
 	message M2G_CreateUnit // IResponse
 	{
-		required int64 UnitId = 1;
-		required int Count = 2;
+		int32 RpcId = 90;
+		int32 Error = 91;
+		string Message = 92;
+
+		int64 UnitId = 1;
+		int Count = 2;
 	}
 
 	message G2M_SessionDisconnect // IActorMessage
 	{
+		int32 RpcId = 90;
+		long ActorId = 94;
 	}
 }

+ 103 - 102
Server/Hotfix/Module/Message/InnerMessage.cs

@@ -8,118 +8,119 @@ namespace ETHotfix
 	[Message(InnerOpcode.M2M_TrasferUnitRequest)]
 	public partial class M2M_TrasferUnitRequest: IRequest
 	{
-		public int RpcId { get; set; }
-		public Unit Unit;
+		public int RpcId { get; set; };
+
+		public Unit Unit { get; set; };
 
 	}
 
 	[Message(InnerOpcode.M2M_TrasferUnitResponse)]
 	public partial class M2M_TrasferUnitResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
-		public long InstanceId;
+		public long InstanceId { get; set; };
 
 	}
 
 	[Message(InnerOpcode.M2A_Reload)]
 	public partial class M2A_Reload: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
 	}
 
 	[Message(InnerOpcode.A2M_Reload)]
 	public partial class A2M_Reload: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
 	}
 
 	[Message(InnerOpcode.G2G_LockRequest)]
 	public partial class G2G_LockRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public long Id;
+		public long Id { get; set; };
 
-		public string Address;
+		public string Address { get; set; };
 
 	}
 
 	[Message(InnerOpcode.G2G_LockResponse)]
 	public partial class G2G_LockResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
 	}
 
 	[Message(InnerOpcode.G2G_LockReleaseRequest)]
 	public partial class G2G_LockReleaseRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public long Id;
+		public long Id { get; set; };
 
-		public string Address;
+		public string Address { get; set; };
 
 	}
 
 	[Message(InnerOpcode.G2G_LockReleaseResponse)]
 	public partial class G2G_LockReleaseResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
 	}
 
 	[Message(InnerOpcode.DBSaveRequest)]
 	public partial class DBSaveRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public bool NeedCache;
+		public bool NeedCache { get; set; };
 
-		public string CollectionName;
+		public string CollectionName { get; set; };
 
-		public ComponentWithId Component;
+		public ComponentWithId Component { get; set; };
 
 	}
 
 	[Message(InnerOpcode.DBSaveBatchResponse)]
 	public partial class DBSaveBatchResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
 	}
 
 	[Message(InnerOpcode.DBSaveBatchRequest)]
 	public partial class DBSaveBatchRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public bool NeedCache;
+		public bool NeedCache { get; set; };
 
-		public string CollectionName;
+		public string CollectionName { get; set; };
 
 		public List<ComponentWithId> Components = new List<ComponentWithId>();
 
@@ -128,61 +129,61 @@ namespace ETHotfix
 	[Message(InnerOpcode.DBSaveResponse)]
 	public partial class DBSaveResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
 	}
 
 	[Message(InnerOpcode.DBQueryRequest)]
 	public partial class DBQueryRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public long Id;
+		public long Id { get; set; };
 
-		public string CollectionName;
+		public string CollectionName { get; set; };
 
-		public bool NeedCache;
+		public bool NeedCache { get; set; };
 
 	}
 
 	[Message(InnerOpcode.DBQueryResponse)]
 	public partial class DBQueryResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
-		public ComponentWithId Component;
+		public ComponentWithId Component { get; set; };
 
 	}
 
 	[Message(InnerOpcode.DBQueryBatchRequest)]
 	public partial class DBQueryBatchRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public string CollectionName;
+		public string CollectionName { get; set; };
 
 		public List<long> IdList = new List<long>();
 
-		public bool NeedCache;
+		public bool NeedCache { get; set; };
 
 	}
 
 	[Message(InnerOpcode.DBQueryBatchResponse)]
 	public partial class DBQueryBatchResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
 		public List<ComponentWithId> Components = new List<ComponentWithId>();
 
@@ -191,22 +192,22 @@ namespace ETHotfix
 	[Message(InnerOpcode.DBQueryJsonRequest)]
 	public partial class DBQueryJsonRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public string CollectionName;
+		public string CollectionName { get; set; };
 
-		public string Json;
+		public string Json { get; set; };
 
 	}
 
 	[Message(InnerOpcode.DBQueryJsonResponse)]
 	public partial class DBQueryJsonResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
 		public List<ComponentWithId> Components = new List<ComponentWithId>();
 
@@ -215,169 +216,169 @@ namespace ETHotfix
 	[Message(InnerOpcode.ObjectAddRequest)]
 	public partial class ObjectAddRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public long Key;
+		public long Key { get; set; };
 
-		public long InstanceId;
+		public long InstanceId { get; set; };
 
 	}
 
 	[Message(InnerOpcode.ObjectAddResponse)]
 	public partial class ObjectAddResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
 	}
 
 	[Message(InnerOpcode.ObjectRemoveRequest)]
 	public partial class ObjectRemoveRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public long Key;
+		public long Key { get; set; };
 
 	}
 
 	[Message(InnerOpcode.ObjectRemoveResponse)]
 	public partial class ObjectRemoveResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
 	}
 
 	[Message(InnerOpcode.ObjectLockRequest)]
 	public partial class ObjectLockRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public long Key;
+		public long Key { get; set; };
 
-		public long InstanceId;
+		public long InstanceId { get; set; };
 
-		public int Time;
+		public int Time { get; set; };
 
 	}
 
 	[Message(InnerOpcode.ObjectLockResponse)]
 	public partial class ObjectLockResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
 	}
 
 	[Message(InnerOpcode.ObjectUnLockRequest)]
 	public partial class ObjectUnLockRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public long Key;
+		public long Key { get; set; };
 
-		public long OldInstanceId;
+		public long OldInstanceId { get; set; };
 
-		public long InstanceId;
+		public long InstanceId { get; set; };
 
 	}
 
 	[Message(InnerOpcode.ObjectUnLockResponse)]
 	public partial class ObjectUnLockResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
 	}
 
 	[Message(InnerOpcode.ObjectGetRequest)]
 	public partial class ObjectGetRequest: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public long Key;
+		public long Key { get; set; };
 
 	}
 
 	[Message(InnerOpcode.ObjectGetResponse)]
 	public partial class ObjectGetResponse: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
-		public long InstanceId;
+		public long InstanceId { get; set; };
 
 	}
 
 	[Message(InnerOpcode.R2G_GetLoginKey)]
 	public partial class R2G_GetLoginKey: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public string Account;
+		public string Account { get; set; };
 
 	}
 
 	[Message(InnerOpcode.G2R_GetLoginKey)]
 	public partial class G2R_GetLoginKey: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
-		public long Key;
+		public long Key { get; set; };
 
 	}
 
 	[Message(InnerOpcode.G2M_CreateUnit)]
 	public partial class G2M_CreateUnit: IRequest
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public long PlayerId;
+		public long PlayerId { get; set; };
 
-		public long GateSessionId;
+		public long GateSessionId { get; set; };
 
 	}
 
 	[Message(InnerOpcode.M2G_CreateUnit)]
 	public partial class M2G_CreateUnit: IResponse
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public int Error { get; set; }
+		public int Error { get; set; };
 
-		public string Message { get; set; }
+		public string Message { get; set; };
 
-		public long UnitId;
+		public long UnitId { get; set; };
 
-		public int Count;
+		public int Count { get; set; };
 
 	}
 
 	[Message(InnerOpcode.G2M_SessionDisconnect)]
 	public partial class G2M_SessionDisconnect: IActorMessage
 	{
-		public int RpcId { get; set; }
+		public int RpcId { get; set; };
 
-		public long ActorId { get; set; }
+		public long ActorId { get; set; };
 
 	}
 

+ 0 - 3
Server/Hotfix/Module/Message/InnerOpcode.cs

@@ -1,6 +1,3 @@
-using ETModel;
-using System.Collections.Generic;
-using MongoDB.Bson.Serialization.Attributes;
 namespace ETHotfix
 {
 	public static partial class InnerOpcode

+ 229 - 0
Unity/Assets/Editor/Proto2CsEditor/InnerProto2CS.cs

@@ -0,0 +1,229 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using ETModel;
+using UnityEditor;
+
+namespace ETEditor
+{
+	[Flags]
+	public enum HeadFlag
+	{
+		None = 0,
+		Bson = 1,
+		Proto = 2,
+	}
+	
+	public static class InnerProto2CS
+	{
+		private const string protoPath = "../Proto/";
+		private const string serverMessagePath = "../Server/Hotfix/Module/Message/";
+		private static readonly char[] splitChars = { ' ', '\t' };
+		private static readonly List<OpcodeInfo> msgOpcode = new List<OpcodeInfo>();
+		
+		
+		public static void Proto2CS()
+		{
+			msgOpcode.Clear();
+			Proto2CS("ETHotfix", "InnerMessage.proto", serverMessagePath, "InnerOpcode", 1000);
+			GenerateOpcode("ETHotfix", "InnerOpcode", serverMessagePath);
+
+			AssetDatabase.Refresh();
+		}
+		
+		public static void Proto2CS(string ns, string protoName, string outputPath, string opcodeClassName, int startOpcode)
+		{
+			msgOpcode.Clear();
+			string proto = Path.Combine(protoPath, protoName);
+			string csPath = Path.Combine(outputPath, Path.GetFileNameWithoutExtension(proto) + ".cs");
+
+			string s = File.ReadAllText(proto);
+
+			StringBuilder sb = new StringBuilder();
+			sb.Append("using ETModel;\n");
+			sb.Append("using System.Collections.Generic;\n");
+			sb.Append($"namespace {ns}\n");
+			sb.Append("{\n");
+
+			bool isMsgStart = false;
+			string parentClass = "";
+			foreach (string line in s.Split('\n'))
+			{
+				string newline = line.Trim();
+
+				if (newline == "")
+				{
+					continue;
+				}
+
+				if (newline.StartsWith("//"))
+				{
+					sb.Append($"{newline}\n");
+				}
+
+				if (newline.StartsWith("message"))
+				{
+					parentClass = "";
+					isMsgStart = true;
+					string msgName = newline.Split(splitChars, StringSplitOptions.RemoveEmptyEntries)[1];
+					string[] ss = newline.Split(new []{"//"}, StringSplitOptions.RemoveEmptyEntries);
+					
+					if (ss.Length == 2)
+					{
+						parentClass = ss[1].Trim();
+					}
+
+					msgOpcode.Add(new OpcodeInfo() { Name = msgName, Opcode = ++startOpcode});
+					
+					sb.Append($"\t[Message({opcodeClassName}.{msgName})]\n");
+					sb.Append($"\tpublic partial class {msgName}");
+					if (parentClass == "IActorMessage" || parentClass == "IActorRequest" || parentClass == "IActorResponse" || parentClass == "IFrameMessage")
+					{
+						sb.Append($": {parentClass}\n");
+					}
+					else if (parentClass != "")
+					{
+						sb.Append($": {parentClass}\n");
+					}
+					else
+					{
+						sb.Append("\n");
+					}
+					continue;
+				}
+
+				if (isMsgStart)
+				{
+					if (newline == "{")
+					{
+						sb.Append("\t{\n");
+						continue;
+					}
+					
+					if (newline == "}")
+					{
+						isMsgStart = false;
+						sb.Append("\t}\n\n");
+						continue;
+					}
+
+					if (newline.Trim().StartsWith("//"))
+					{
+						sb.AppendLine(newline);
+						continue;
+					}
+
+					if (newline.Trim() != "" && newline != "}")
+					{
+						if (newline.StartsWith("repeated"))
+						{
+							Repeated(sb, ns, newline);
+						}
+						else
+						{
+							Members(sb, newline, true);
+						}
+					}
+				}
+			}
+			sb.Append("}\n");
+
+			File.WriteAllText(csPath, sb.ToString());
+		}
+
+		private static void GenerateOpcode(string ns, string outputFileName, string outputPath)
+		{
+			StringBuilder sb = new StringBuilder();
+			sb.AppendLine($"namespace {ns}");
+			sb.AppendLine("{");
+			sb.AppendLine($"\tpublic static partial class {outputFileName}");
+			sb.AppendLine("\t{");
+			foreach (OpcodeInfo info in msgOpcode)
+			{
+				sb.AppendLine($"\t\t public const ushort {info.Name} = {info.Opcode};");
+			}
+			sb.AppendLine("\t}");
+			sb.AppendLine("}");
+			
+			string csPath = Path.Combine(outputPath, outputFileName + ".cs");
+			File.WriteAllText(csPath, sb.ToString());
+		}
+
+		private static void Repeated(StringBuilder sb, string ns, string newline)
+		{
+			try
+			{
+				int index = newline.IndexOf(";");
+				newline = newline.Remove(index);
+				string[] ss = newline.Split(splitChars, StringSplitOptions.RemoveEmptyEntries);
+				string type = ss[1];
+				type = ConvertType(type);
+				string name = ss[2];
+
+				sb.Append($"\t\tpublic List<{type}> {name} = new List<{type}>();\n\n");
+			}
+			catch (Exception e)
+			{
+				Log.Error($"{newline}\n {e}");
+			}
+
+		}
+
+		private static string ConvertType(string type)
+		{
+			string typeCs = "";
+			switch (type)
+			{
+				case "int16":
+					typeCs = "short";
+					break;
+				case "int32":
+					typeCs = "int";
+					break;
+				case "bytes":
+					typeCs = "byte[]";
+					break;
+				case "uint32":
+					typeCs = "uint";
+					break;
+				case "long":
+					typeCs = "long";
+					break;
+				case "int64":
+					typeCs = "long";
+					break;
+				case "uint64":
+					typeCs = "ulong";
+					break;
+				case "uint16":
+					typeCs = "ushort";
+					break;
+				default:
+					typeCs = type;
+					break;
+			}
+			return typeCs;
+		}
+
+		private static void Members(StringBuilder sb, string newline, bool isRequired)
+		{
+			try
+			{
+				int index = newline.IndexOf(";");
+				newline = newline.Remove(index);
+				string[] ss = newline.Split(splitChars, StringSplitOptions.RemoveEmptyEntries);
+				string type = ss[0];
+				string name = ss[1];
+				string typeCs = ConvertType(type);
+
+				sb.Append($"\t\tpublic {typeCs} {name} {{ get; set; }};\n\n");
+			}
+			catch (Exception e)
+			{
+				Log.Error($"{newline}\n {e}");
+			}
+
+		}
+	}
+}

+ 11 - 0
Unity/Assets/Editor/Proto2CsEditor/InnerProto2CS.cs.meta

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

+ 10 - 4
Unity/Assets/Editor/Proto2CsEditor/Proto2CSEditor.cs

@@ -8,7 +8,7 @@ using UnityEditor;
 
 namespace ETEditor
 {
-	class OpcodeInfo
+	internal class OpcodeInfo
 	{
 		public string Name;
 		public int Opcode;
@@ -25,6 +25,9 @@ namespace ETEditor
 		[MenuItem("Tools/Proto2CS")]
 		public static void AllProto2CS()
 		{
+			// InnerMessage.proto生成cs代码
+			InnerProto2CS.Proto2CS();
+			
 			msgOpcode.Clear();
 			Proto2CS("ETModel", "OuterMessage.proto", clientMessagePath, "OuterOpcode", 100);
 			
@@ -32,6 +35,8 @@ namespace ETEditor
 			msgOpcode.Clear();
 			Proto2CS("ETHotfix", "HotfixMessage.proto", hotfixMessagePath, "HotfixOpcode", 10000);
 
+			CommandRun($"protoc.bat", "");
+
 			AssetDatabase.Refresh();
 		}
 
@@ -41,12 +46,13 @@ namespace ETEditor
 			{
 				ProcessStartInfo info = new ProcessStartInfo
 				{
+					CreateNoWindow = true,
 					FileName = exe, 
 					Arguments = arguments, 
 					UseShellExecute = true,
-					WorkingDirectory = "."
 				};
-				Process.Start(info);
+				Process p = Process.Start(info);
+				p.WaitForExit();
 			}
 			catch (Exception e)
 			{
@@ -59,7 +65,7 @@ namespace ETEditor
 			msgOpcode.Clear();
 			string proto = Path.Combine(protoPath, protoName);
 			
-			CommandRun($"protoc.exe", $"--csharp_out=\"{outputPath}\" --proto_path=\"{protoPath}\" {protoName}");
+			//CommandRun($"protoc.exe", $"--csharp_out=\"./{outputPath}\" --proto_path=\"{protoPath}\" {protoName}");
 
 			string s = File.ReadAllText(proto);
 

+ 5 - 0
Unity/protoc.bat

@@ -0,0 +1,5 @@
+@echo off
+protoc.exe --csharp_out="./Assets/Scripts/Module/Message/" --proto_path="../Proto/" OuterMessage.proto
+protoc.exe --csharp_out="./Hotfix/Module/Message/" --proto_path="../Proto/" HotfixMessage.proto
+echo finish... 
+pause