Skip to content

Instantly share code, notes, and snippets.

@naojitaniguchi
Created August 4, 2016 03:42
Show Gist options
  • Save naojitaniguchi/2f3066d217425051913e1577251dab07 to your computer and use it in GitHub Desktop.
Save naojitaniguchi/2f3066d217425051913e1577251dab07 to your computer and use it in GitHub Desktop.
Get OSC message by UniOSC
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using OSCsharp.Data;
namespace UniOSC{
public class UniOSCGetMessage : UniOSCEventTarget {
public GameObject[] fireObjects ;
public GameObject score ;
private int fireCount = 0 ;
void Awake(){
}
private void _Init(){
}
public override void OnEnable(){
_Init();
base.OnEnable();
}
public override void OnOSCMessageReceived(UniOSCEventArgs args){
Debug.Log ( "Address:" + args.Address );
// args.Address
OscMessage msg = (OscMessage)args.Packet;
if(msg.Data.Count <1)return;
if ( args.Address == "/hit" ){
GameObject.Instantiate( fireObjects[fireCount%fireObjects.Length] );
fireCount ++ ;
score.GetComponent<ScoreCount>().addScore();
}
Debug.Log( args.Address );
//if ( msg.Data.Count >= 2 ){
//int type = (int)msg.Data[0];
//float sec = (float)msg.Data[1];
//if ( args.Address == "/hit"){
//}
//}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment