Iam1337 / extOSC

extOSC is a tool dedicated to simplify creation of applications in Unity with OSC protocol usage.
MIT License
193 stars 25 forks source link
csharp csharp-code editor-extension extosc framework opensoundcontrol osc osc-protocol osc-receiver oscmessage unity unity-editor unity3d unity3d-plugin

extOSC - Open Sound Control Protocol for Unity

Created by iam1337

⚙ Build and Release openupm semantic-release: angular

Table of Contents

Introduction

extOSC (Open Sound Control Protocol) is a tool dedicated to simplify creation of applications with OSC protocol usage in Unity (Unity3d). Supported platforms are PC, Mac and Linux / iOS / tvOS / Android / Universal Windows Platform (UWP) and other.

Also extOSC is available on the Unity Asset Store for free.

Features:

And also:

And much more

Installation

Old school

Just copy the Assets/extOSC folder into your Assets directory within your Unity project, or download latest extOSC.unitypackage.

OpenUPM

Via openupm-cli:

openupm add com.iam1337.extosc

Or if you don't have it, add the scoped registry to manifest.json with the desired dependency semantic version:

"scopedRegistries": [
    {
        "name": "package.openupm.com",
        "url": "https://package.openupm.com",
        "scopes": [
            "com.iam1337.extosc",
        ]
    }
],
"dependencies": {
    "com.iam1337.extosc": "1.19.7"
}

Package Manager

Project supports Unity Package Manager. To install the project as a Git package do the following:

  1. In Unity, open Window > Package Manager.
  2. Press the + button, choose "Add package from git URL..."
  3. Enter "https://github.com/iam1337/extOSC.git#upm" and press Add.

Examples

Create OSC Transmitter

// Creating a transmitter.
var transmitter = gameObject.AddComponent<OSCTransmitter>();

// Set remote host address.
transmitter.RemoteHost = "127.0.0.1";    

// Set remote port;
transmitter.RemotePort = 7001;         

Or you can simple create OSCTransmitter component in Unity editor, or use Create/extOSC/OSC Manager in Hierarchy window.

Send OSCMessage

// Create message
var message = new OSCMessage("/message/address");

// Populate values.
message.AddValue(OSCValue.String("Hello, world!"));
message.AddValue(OSCValue.Float(1337f));

// Send message
transmitter.Send(message);      

Or you can use any extOSC/Transmitter components.

Create OSC Receiver

// Creating a receiver.
var receiver = gameObject.AddComponent<OSCReceiver>(); 

// Set local port.
receiver.LocalPort = 7001;            

Or you can simple create OSCReceiver component in Unity editor, or use Create/extOSC/OSC Manager in Hierarchy window.

Receive OSCMessage

Bind method to special address. In address argument you can use masks like: "/message/*"

// Bind "MessageReceived" method to special address.
receiver.Bind("/message/address", MessageReceived);     

Method realization:

protected void MessageReceived(OSCMessage message)
{
    // Any code...
    Debug.Log(message);
}

Or you can use any extOSC/Receiver components.

Get value from OSCMessage

You have two ways to get the value from the message.

var value = message.Values[0].FloatValue;
// Any code...
Debug.Log(value);

or

if (message.ToFloat(out var value))  
{
    // Any code...
    Debug.Log(value);
}

Other examples you can find in Examples folder.

Extensions

List of useful repositories to help make extDebug easier to use:

Author Contacts

> telegram.me/iam1337
> ext@iron-wall.org

License

This project is under the MIT License.