void Awake() { //Here we show the different possibilities to create a OSCEventTarget from code: //When we only specify a port we listen to all OSCMessages on that port (We assume that there is a OSCConnection with that listening port in our scene) oscTarget1 = new UniOSCEventTargetCBImplementation(OSCPort); oscTarget1.OSCMessageReceived += OnOSCMessageReceived1; //oscTarget1.oscPort = OSCPort; //This implies that we use the explicitConnection mode. (With responding to all OSCmessages) oscTarget2 = new UniOSCEventTargetCBImplementation(OSCConnection); oscTarget2.OSCMessageReceived += OnOSCMessageReceived2; //We listen to a special OSCAddress regardless of the port. oscTarget3 = new UniOSCEventTargetCBImplementation(OSCAddress); oscTarget3.OSCMessageReceived += OnOSCMessageReceived3; //The standard : respond to a given OSCAddress on a given port oscTarget4 = new UniOSCEventTargetCBImplementation(OSCAddress, OSCPort); oscTarget4.OSCMessageReceived += OnOSCMessageReceived4; //This version has the advantage that we are not bound to a special port. If the connection changes the port we still respond to the OSCMessage oscTarget5 = new UniOSCEventTargetCBImplementation(OSCAddress, OSCConnection); oscTarget5.OSCMessageReceived += OnOSCMessageReceived5; oscDispatcher1 = new UniOSCEventDispatcherCBImplementation(OSCAddressOUT, OSCIPAddressOUT, OSCPortOUT); oscDispatcher1.AppendData("TEST1"); oscDispatcher2 = new UniOSCEventDispatcherCBImplementation(OSCAddressOUT, OSCConnectionOUT); OSCConnection.transmissionTypeIn = OSCsharp.Net.TransmissionType.Multicast; OSCConnection.oscInIPAddress = "224.0.0.1";//Set a valid Multicast address. }
void OnDestroy() { //Clean up things and release recources!!!! //Otherwise our callbacks can still respond even if our GameObject with this script is destroyed/removed from the scene oscTarget.Dispose (); oscTarget = null; }
void Awake() { injectorArray = FindObjectsOfType (typeof(UniOSCInjector)) as UniOSCInjector[]; injectorList = injectorArray.ToList(); foreach (UniOSCInjector inject in injectorList) { Debug.Log("Address: " + inject.Address + " Value: " + inject.Value + "Enabled" + inject.On); } oscTarget = new UniOSCEventTargetCBImplementation(OSCConnection); oscTarget.OSCMessageReceived+=OnOSCMessageReceived; }
void OnDestroy() { //Clean up things and release recources!!!! //Otherwise our callbacks can still respond even if our GameObject with this script is destroyed/removed from the scene oscTarget1.Dispose(); oscTarget1 = null; oscTarget2.Dispose(); oscTarget2 = null; oscTarget3.Dispose(); oscTarget3 = null; oscTarget4.Dispose(); oscTarget4 = null; oscTarget5.Dispose(); oscTarget5 = null; }