小编Nop*_*p0x的帖子

protobuf-net无法反序列化我的课程

我想序列化一个'Player'类,并通过我的网络流发送给客户端.

球员类

    [ProtoMember(1)]
    public int flag;
    [ProtoMember(2)]
    public Int16 id;
    [ProtoMember(3)]
    public MyVector3 CharPos;
    [ProtoMember(7)]
    public bool spawned;
Run Code Online (Sandbox Code Playgroud)

MyVector3(由于protobuf不支持序列化的事实Vector3)

[ProtoContract]
public class MyVector3
{
    [ProtoMember(4)]
    public float X { get; set; }

    [ProtoMember(5)]
    public float Y { get; set; }

    [ProtoMember(6)]
    public float Z { get; set; }

    public MyVector3()
    {
        this.X = 0.0f;
        this.Y = 0.0f;
        this.Z = 0.0f;
    }

    public MyVector3(float x, float y, float z)
    {
        this.X = x;
        this.Y = y;
        this.Z = …
Run Code Online (Sandbox Code Playgroud)

c# protobuf-net

4
推荐指数
1
解决办法
4366
查看次数

标签 统计

c# ×1

protobuf-net ×1