手机运行 Unity Grpc

栏目: 编程语言 · 发布时间: 7年前

内容简介:手机运行 Unity Grpc(金庆的专栏 2018.8)

手机运行 Unity Grpc

(金庆的专栏 2018.8)

  • 安装 Unit2018, 支持 .NET 4.x
  • 创建一个项目,开启 .NET 4.x
    Edit->Project Settings->Player->Other Settings
    ->Configuration->Script Runtime Version->.Net 4.x Equivalent
  • https://packages.grpc.io/ 的 Daily Builds 下载最新的
    grpc-protoc_windows_x86-VERSION.zip
    grpc_unity_package.VERSION.zip
  • grpc_unity_package.VERSION.zip
    解压到 Assets 目录下
  • 从 github grpc 复制 examples/protos/helloworld.proto 为 Assets/protos/helloworld.proto
  • 创建 Assets/Scripts/Greeter/, 并在该目录下运行
     
    
    protoc.exe -I../../../protos --csharp_out=. ../../../protos/helloworld.proto --grpc_out=. --plugin=protoc-gen-grpc=grpc_csharp_plugin.exe 
    
    
    • 需要先从 grpc-protoc_windows_x86-VERSION.zip 解压 protoc.exe,grpc_csharp_plugin.exe
    • 生成 Helloworld.cs HelloworldGrpc.cs
  • 客户端代码
    • 创建Channel连接服务器
       
      
      channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure); 
      
      
    • 创建客户端并发出请求
       
      
      var client = new Greeter.GreeterClient(channel); 
      
      HelloReply reply = client.SayHello(new HelloRequest { Name = "Jin Qing" }); 
      
      
  • 完整代码见: https://gitee.com/jinq0123/unity-grpc-sample
  • 最后打包安装到手机测试通过

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Introduction to Computer Science Using Python

Introduction to Computer Science Using Python

Dierbach, Charles / 2012-12 / $ 133.62

Introduction to Computer Science Using Python: A Computational Problem-Solving Focus introduces students to programming and computational problem-solving via a back-to-basics, step-by-step, objects-la......一起来看看 《Introduction to Computer Science Using Python》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码