Home - CaptainToTo/owl-tree-unity GitHub Wiki
OwlTree Unity Add-On
Add-on that provides OwlTree support for Unity. This includes the latest OwlTree version, as well as other add-ons that will provide extra utility within Unity.
OwlTree is a framework which exists outside of Unity. Read the primary framework documentation here to gain a better understanding of the full suite of tools available to you.
Set-Up
To add OwlTree to your Unity project, download the latest unity package here, and import it into your project.
Thats It!
Making A Connection
OwlTree.Unity's primary interface is the UnityConnection component. To start off create a new empty gameobject, and attach a UnityConnection to it, then make it a prefab.
Then, right click on the Project/File Explorer window and select Create > OwlTree > ConnectionArgs. This scriptable object contains arguments that will be used configure a connection. Open the "verbosity" option, and enable "Client Events", "Connection Attempts", and "Exceptions".
Next, make a new script called ConnectionRunner and attach it to the Connection prefab. Put the following code:
using OwlTree.Unity;
using UnityEngine;
public class ConnectionRunner : MonoBehaviour
{
[SerializeField] ConnectionArgs args;
void Awake()
{
var connection = GetComponent<UnityConnection>();
connection.Connect(args.GetArgs());
}
}
Currently, the connection is configured to behave as a client, meaning you'll need a server to connect to.
For local testing, OwlTree provides a simple relay server you can download from here. This is a separate C# program that runs on the .NET runtime. You can start the server by opening a terminal in the server project folder, and running:
> dotnet run
You can learn more about how to use the relay server from its documentation.
You can press play in the Unity editor, and the follow messages should appear in the console:
This shows your Unity client successfully connected to your relay server.
Examples
You can view an example project using OwlTree in Unity here. This is relayed peer-to-peer farming game.