Skip to content

Instantly share code, notes, and snippets.

@naojitaniguchi
Created November 29, 2016 00:28
Show Gist options
  • Save naojitaniguchi/5a7ea4d0481fec7bfcbaec6ff2f204b2 to your computer and use it in GitHub Desktop.
Save naojitaniguchi/5a7ea4d0481fec7bfcbaec6ff2f204b2 to your computer and use it in GitHub Desktop.
Message sending sample for UniOSC
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System;
using OSCsharp.Data;
namespace UniOSC{
public class UniOSCSendMessageSample: UniOSCEventDispatcher {
public override void Awake()
{
base.Awake ();
}
public override void OnEnable ()
{
base.OnEnable ();
ClearData();
AppendData("MyString");// string data at index [2]
}
public override void OnDisable ()
{
base.OnDisable ();
}
public void SendStringByOSCMessage(string messageStr ){
// float downOSCDataValue = 0.0f ;
if(_OSCeArg.Packet is OscMessage)
{
((OscMessage)_OSCeArg.Packet).UpdateDataAt(0, messageStr);
}
else if(_OSCeArg.Packet is OscBundle)
{
foreach (OscMessage m in ((OscBundle)_OSCeArg.Packet).Messages)
{
m.UpdateDataAt(0, messageStr);
}
}
_SendOSCMessage(_OSCeArg);
}
public void ConnectToOSCConnections(){
_ConnectToOSCConnections();
}
public void setOutIPAddressToOSCArg( string outIPAddress ){
_OSCeArg.IPAddress = outIPAddress;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment