using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
public class msg : MonoBehaviour {
public string RemoteIP = "127.0.0.1";
public int SendToPort = 9000;
public int ListenerPort = 7878;
public GameObject[] receiverGameObjects;
private Osc handler;
private UDPPacketIO udp;
void Start () {
udp = new UDPPacketIO();
udp.init(RemoteIP,SendToPort,ListenerPort);
handler = new Osc();
handler.init(udp);
//handler.SetAllMessageHandler(Msg);
handler.SetAddressHandler("/chan1", Msg);
handler.SetAddressHandler("/chan2", Msg2);
}
void OnDisable()
{
udp.Close();
}
private void OnDestroy()
{
udp.Close();
}
void Update () {
}
public void Msg(OscMessage oscMessage)
{
string msgString = Osc.OscMessageToString(oscMessage);
string[] aa= msgString.Split(' ');
Debug.Log(aa[1]);
}
public void Msg2(OscMessage oscMessage)
{
string msgString = Osc.OscMessageToString(oscMessage);
Debug.Log("信息为: " + msgString);
}
}
osc
最新推荐文章于 2023-01-31 11:50:17 发布