From 588c8850ea1f530eabca408badeca2b146483536 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Thu, 6 Nov 2025 15:32:54 +0800 Subject: [PATCH] =?UTF-8?q?protobuff=20=E6=B7=BB=E5=8A=A0=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E9=9B=86=E5=BC=95=E7=94=A8=20=E5=92=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BD=BF=E7=94=A8MergeFromEx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Script/AppMain/AxibugEmuOnline.Client.asmdef | 3 ++- .../Assets/Script/AppMain/Common/ProtoBufHelper.cs | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxibugEmuOnline.Client.asmdef b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxibugEmuOnline.Client.asmdef index ebbd05e2..cac2e137 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxibugEmuOnline.Client.asmdef +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxibugEmuOnline.Client.asmdef @@ -10,7 +10,8 @@ "StoicGooseUnity", "Unity.InputSystem", "AxiNSApi", - "Unity.InputSystem.Switch" + "Unity.InputSystem.Switch", + "Google.Protobuf" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ProtoBufHelper.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ProtoBufHelper.cs index 9fc6d905..32d07206 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ProtoBufHelper.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ProtoBufHelper.cs @@ -8,6 +8,7 @@ namespace AxibugEmuOnline.Client.Common public static class ProtoBufHelper { private static ProtobufferMsgPool _msgPool = new ProtobufferMsgPool(); + static CodedInputStream codedInputStream = new CodedInputStream(); public static void RentSerizlizeData(IMessage msg, out byte[] data, out int usedlength) { @@ -28,14 +29,17 @@ namespace AxibugEmuOnline.Client.Common { var msgType = typeof(T); object msg = _msgPool.Get(msgType); - ((IMessage)msg).MergeFrom(bytes); + //((IMessage)msg).MergeFrom(bytes); + ((IMessage)msg).MergeFromEx(codedInputStream, bytes, 0, bytes.Length); return (T)msg; } + public static IMessage DeSerizlizeFromPool(byte[] bytes, Type protoType) { var msgType = protoType; object msg = _msgPool.Get(msgType); - ((IMessage)msg).MergeFrom(bytes); + //((IMessage)msg).MergeFrom(bytes); + ((IMessage)msg).MergeFromEx(codedInputStream, bytes, 0, bytes.Length); return (IMessage)msg; } public static void ReleaseToPool(IMessage msg)