Giter Club home page Giter Club logo

protobuf_for_unity's Introduction

protobuf_for_unity

google's protobuf 3.x for unity3D

来源: google's protobuf
版本号:3.x

使用方法:
将目录 Google.Protobuf 下的所有文件拷到 Unity 工程中。


接下来可以参考 test_msg.proto

syntax = "proto3";

message TheMsg {
  string name = 1;
  int32 num = 2;
}

以及 Test.cs

void Start ()
{
    TheMsg msg = new TheMsg();
    msg.Name = "am the name";
    msg.Num = 32;

    Debug.Log(string.Format("The Msg is ( Name:{0},Num:{1} )",msg.Name,msg.Num));

    byte[] bmsg;
    using (MemoryStream ms = new MemoryStream())
    {
        msg.WriteTo(ms);
        bmsg = ms.ToArray();
    }


    TheMsg msg2 = TheMsg.Parser.ParseFrom(bmsg);
    Debug.Log(string.Format("The Msg2 is ( Name:{0},Num:{1} )",msg2.Name,msg2.Num));

}

测试输出:


protobuf_for_unity's People

Contributors

gongfaxin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.