UnityCommon/Proto/ProtoBufffer.cs

29 lines
581 B
C#
Raw Normal View History

2024-12-04 10:08:59 +08:00
using Google.Protobuf;
using System;
public class ProtoBufffer
{
public static byte[] Serialize(IMessage message)
{
return message.ToByteArray();
}
public static T DeSerialize<T>(byte[] packet) where T : IMessage, new()
{
IMessage message = new T();
try
{
return (T)message.Descriptor.Parser.ParseFrom(packet);
}
catch (System.Exception e)
{
throw;
}
}
internal static T DeSerialize<T>(ByteString data)
{
throw new NotImplementedException();
}
}