Skip to content

Banyanunity is a package built upon the python-banyan framework. Using lightweight asynchronous socket communication, Banyanunity enables two-way communication between Unity's game environment and Python applications.

Notifications You must be signed in to change notification settings

NoahMoscovici/banyanunity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Banyan Unity

Overview

Banyan Unity is a package built upon the python-banyan framework, allowing two-way communication between Unity's game environment and python applications using lightweight asynchronous socket communication. You can view the installation guide here.

You can view the Unity Asset Store counterpart with its respective documentation here.

Prerequisites

For this package you will need Python 3, Python Banyan, and Unity all installed. A general understanding of Alan Yorinks' Python Banyan is highly recommended.

Overview on Banyan Unity architecture

banyanunity diagram

Below is a brief explanation on the purpose of each component. Both the Python and C# components of Banyan Unity are located in this GitHub repository.

TcpConnectedClient.cs

The framework used for the Unity C# programs were originally based on the TCP & UDP chat framework developed by HardlyDifficult. You can see a more in-depth guide on this implemented structure here.

test_unity_sender_cube.py

This script acts as a demonostration of how one might use Python Banyan to send messages through the Backplane. Each topic starts in a python dictionary format, which is converted JSON before sent.

unitygateway.py

unitygateway.py uses the Python Banyan framework to constantly listen for messages in the receive_loop(), then processing those messages in incoming_message_processing(). While being processed, if the incoming topic is send_to_unity, the message will be forwarded to BanyanMessageListener.cs in the Unity environment (through port 5000).

BanyanMessageListener.cs

BanyanMessageListener.cs listens to unitygateway.py on port 5000. Once receiving a message, the script will decode it and forward the payload off to MessageProcessor.cs on a Unity object.

MessageProcessor.cs

MessageProcessor.cs will perform an action (in the example, turn the cube a certain color) based on the method DoAction() after being called by BanyanMessageListener.cs. The script will then use BanyanMessageSender.cs to send a message back to the Python Banyan environment.

BanyanMessageSender.cs

BanyanMessageSender.cs sends a message to unitylistener.py on port 5001 after being called from MessageProcessor.cs.

unitylistener.py

unitylistener.py listens on port 5001 for messages being sent by BanyanMessageSender.cs in the Unity environment. Once receiving a message, unitylistener.py decodes the message and forwards it to the Python Banyan Backplane with the topic of receive_unity_message.


For further help on installation or other inquiries, feel free to contact me at [email protected]

About

Banyanunity is a package built upon the python-banyan framework. Using lightweight asynchronous socket communication, Banyanunity enables two-way communication between Unity's game environment and Python applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published