Coder Social home page Coder Social logo

connectpy's Introduction

Unity和Python之间Socket通信

现在使用Python 为基础的机器学习工具越来越多了,例如Tensorflow。

很多项目都是使用python来train自己的模型,训练完毕之后,然后导出graph (.bytes文件)。之后复制到unity中加载表现。

unity官方的mechine-learning 例子,就是遵循这样的原则。unity例子github下载链接:https://github.com/Unity-Technologies/ml-agents

本示例以最简洁的代码,展示了unity和python之间的通信。

操作步骤如下:

  1. 打开unity 项目,点击运行

  2. 进入Python, 选择main.py 编译运行 此时服务器socket进入监听状态

  3. 点击第一个按钮,建立CS连接。 此时服务器的日志可以看到客户端发过来的字段。

  4. 点击第二个按钮,客户端不间断的发送Hello World给server

  5. 点击第三个按钮,服务器端会发送一个json给客户端

  6. 点击第十四个按钮,socket 会断开连接

注意:

socket如何30秒没有连接,服务器会主动断开连接

connectpy's People

Contributors

huailiang avatar

Watchers

James Cloos 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.