Unity Community


Page 1 of 3 123 LastLast
Results 1 to 20 of 58

  1. Posts
    40

    MIDI or OSC for Unity Indie users?

    Does anyone have any ideas about how i can use/get MIDI or OSC control inside a unity game?

    (aside from that MIDI plugin someone made that only works in Unity Pro)


  2. Location
    NE Ohio, USA
    Posts
    7,173
    As far as I know, you're out of luck for the time being. If MIDI/OSC gets implemented in an official release of ControllerMate, that will probably be your best bet.

    http://www.orderedbytes.com/forum/vi...8cb03382b4857b

  3. Unity Developer



    Posts
    367
    I'm currently using OSC in Unity. There is a (very basic) implementation of the OSC protocol in C# available at http://www.makingthings.com/ref/dotnet/html/ , which is what I use.


  4. Location
    new york, US
    Posts
    2
    Jonas, any chance you could post some example code? That would be really helpful...
    thanks

  5. Unity Developer



    Posts
    367
    Download their SDK from http://downloads.sourceforge.net/mak...ngs/dotnet.zip

    The source files you are interested in are Osc.cs and Packet.cs. These compile in unity (I think I had to do some very minor modifications to make them compile). Then you can just send and receive OSC messages, as documented in:

    http://www.makingthings.com/ref/dotnet/html/


  6. Location
    LightWave 3D
    Posts
    191
    anyone wanna hazard a javascript port?
    You are the cattle, I am the catalyst.


  7. Posts
    5
    If you are using Maxon's C4D R11.x with Unity 3D try:

    Python for C4D plugin:
    http://www.py4d.com/2009/09/py4d-0-9-9980-rc/

    in conjunction with

    Python SimpleOSC:
    http://www.ixi-software.net/content/...kyard_osc.html


  8. Location
    Brooklyn, NY
    Posts
    25
    For those who are wanting to use OSC with Unity, I am attaching an example project that shows a bare bones hello world for receiving messages.

    It is based off the above mentioned MakingThings library but has been modified to compile in unity, and comes with a project showing how to set it up.

    Hope it helps someone out there!
    Attached Files


  9. Posts
    1
    Hi, that's very cool! Could you please add a OSC Send JavaScript example as well? I am trying to get it work, but still fail...

    EDIT: I was able to finally come up with the right syntax, so just add this function to the above code:

    Code:  
    1. public function sendOSC(txt : String){ 
    2. handler.Send(handler.StringToOscMessage(txt));
    3. }

    Thanks to obviousjim


  10. Location
    Brooklyn, NY
    Posts
    25
    Seems that there is a pretty good set of osc code wrapped into this TUIO example I came across

    http://forum.unity3d.com/viewtopic.php?p=82916 (see downloadable file)

    That should get you set up with an OSC Sender.


  11. Posts
    3
    Mhhhh i have a problem to build the osc example. if i press play in unity it works, but after building nothing happens. I use the old 2.5 Indie version, is this a problem? or should i implements something in the builded file? I'm workin on a mac...


  12. Location
    Zurich, CH
    Posts
    8

    Unity OSC C#

    Quote Originally Posted by obviousjim
    For those who are wanting to use OSC with Unity, I am attaching an example project that shows a bare bones hello world for receiving messages.

    It is based off the above mentioned MakingThings library but has been modified to compile in unity, and comes with a project showing how to set it up.

    Hope it helps someone out there!
    Thank you very much for this example. I implemented a C# starter script instead of the javascript one. And run into two funny problems
    1. The udp listener thread is not stopping and continues to run even when the game is stopped
    2. The udp port is not freed when restarting the game (play-stop-play).

    This will give also strange timeouts when pressing play a second time - having to wait for some seconds until the game really starts.

    To workaround these problems, I found the following solution (I can also post the C# script here if anyone is interested):
    1. The starter script needs to implement an object destructor that calls the function oscHandler.Cancel()
    2. The udp listener thread in Osc.cs should be a foreground thread (set ReadThread.IsBackground=false in Osc.init). This will ensure that the thread can be terminated normally (when pressing stop) and the socket can be freed.

    This way, OSC works perfectly in Unity. To test with the example code above, I can also recommend the (osc.M monitor or OSCMonitor - on Windows platforms).

    Cheers, Kai

    PS. I just realized one more thing: the c# callback function to be used with oscHandler.SetAddressHandler() should be declared static. Otherwise the solution above will not work at all because the destructor is never called. I guess the GC cannot resolve the cyclic reference.

    All this would not be a problem, if there would be a stop method for the GameObject (that is called when the game is stopped in the editor) - then we could clean up properly. Is there maybe such a method?


  13. Posts
    112

    Re: Unity OSC C#

    Quote Originally Posted by kjauslin

    To workaround these problems, I found the following solution (I can also post the C# script here if anyone is interested):
    Interested! Please post.


  14. Location
    Zurich, CH
    Posts
    8

    Re: Unity OSC C#

    Quote Originally Posted by dpentecost
    Interested! Please post.
    Ok, here is the working example (the code from above, but full c# and bugfixes for init/closing udp socket). It runs now very nicely. The correct way is to implement the "OnDisable" method and close the udp socket there.

    It still gives a warning, that the listener socket is already in use, but you can ignore it and messages arrive nevertheless. I have tested with a C++ program using OSCpack (send and receive OSC messages).

    A nice addition to better work with OSCpack would be some OSC 1.1 features (e.g. boolean types)... anyone?

    Regards, Kai
    Attached Files


  15. Posts
    112


  16. Posts
    112
    Thanks to obviousjim and Kai - I got both receive and send tests working with TouchOSC on the iPhone and OSCulator on the Mac.


  17. Posts
    8

    Error with received osc packets

    Hello, im with a little problem when I run that example this happens

    Code:  
    1. cannot open udp client interface at port 9287
    2. UnityEngine.Debug:LogWarning(Object)
    3. UDPPacketIO:Open() (at Assets\Plugins\UDPPacketIO.cs:61)
    4. UDPPacketIO:SendPacket(Byte[], Int32) (at Assets\Plugins\UDPPacketIO.cs:108)
    5. Osc:Send(OscMessage) (at Assets\Plugins\Osc.cs:248)
    6. OSCTestSender:Update() (at Assets\scripts\OSCTestSender.cs:40)

    And this:

    Code:  
    1. System.Net.Sockets.SocketException: Address already in use
    2.   at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00000]
    3.   at System.Net.Sockets.UdpClient.InitSocket (System.Net.EndPoint localEP) [0x00000]
    4.   at System.Net.Sockets.UdpClient..ctor (System.Net.IPEndPoint localEP) [0x00000]
    5.   at UDPPacketIO.Open () [0x0001c] in C:\Documents and Settings\user\Desktop\osc_example_662\osc_example\Assets\Plugins\UDPPacketIO.cs:54
    6. UnityEngine.Debug:LogWarning(Object)
    7. UDPPacketIO:Open() (at Assets\Plugins\UDPPacketIO.cs:62)
    8. UDPPacketIO:SendPacket(Byte[], Int32) (at Assets\Plugins\UDPPacketIO.cs:108)
    9. Osc:Send(OscMessage) (at Assets\Plugins\Osc.cs:248)
    10. OSCTestSender:Update() (at Assets\scripts\OSCTestSender.cs:40)

    And I really sure what that port is open without other application running.

    I tried with other port and get same error. I sending with oscP5 (for Processing) and this app get unity3D messages.

    Someone knows what how I can fix it?

    PS: I try run in MAC and the same error appear.

    Thanks.
    Attached Files


  18. Posts
    112
    I got a pm from another beginner asking how I had gotten this to work. So I have put together a project that combines the previous two (both send and receive), added a screenshot and a readme. It still just confirms send and receive in the console - no manipulation of objects in Unity yet.

    EDIT: Check my post a few posts down from this one, for a downloadable demo that does manipulate Unity objects.

    Hope it helps someone else. All the pieces were there but if you are not a coder (I am not) it can be a bit confusing.

    The readme includes links to TouchOSC, OSCulator, and oscP5.

    Good luck!

    PS psydack - My guess is that you will have to play with your IP and port settings to get it right. Check what ports Processing is using.
    Attached Files


  19. Posts
    8
    Quote Originally Posted by dpentecost
    I got a pm from another beginner asking how I had gotten this to work. So I have put together a project that combines the previous two (both send and receive), added a screenshot and a readme. It still just confirms send and receive in the console - no manipulation of objects in Unity yet.

    Hope it helps someone else. All the pieces were there but if you are not a coder (I am not) it can be a bit confusing.

    The readme includes links to TouchOSC, OSCulator, and oscP5.

    Good luck!

    PS psydack - My guess is that you will have to play with your IP and port settings to get it right. Check what ports Processing is using.
    Thanks, I'm really like but I'm got confused now! I'm get your way, step by step and nothing.

    Im really don't know what happens. I'm now using one PC with Processing (192.168.1.110) and other Mac using Unity (192.168.1.103). I already test with inverting the programs (PC with Unity and Mac with Processing) and both tests Processing work normally.

    I'd put a print screen with I'm using Mac with Unity don't working. I'm tried others ports and I'm tried with runs every at same local: Mac with Processing and Unity3D and PC with Unity3D and Processing.

    The other Script wich only send(with the error when try to open but send) I'm realized some tests with Processing and it works. But this don't received only send.


    Sorry for something and thanks for all!
    Attached Files


  20. Location
    Zurich, CH
    Posts
    8
    Quote Originally Posted by psydack

    Thanks, I'm really like but I'm got confused now! I'm get your way, step by step and nothing.

    Im really don't know what happens. I'm now using one PC with Processing (192.168.1.110) and other Mac using Unity (192.168.1.103). I already test with inverting the programs (PC with Unity and Mac with Processing) and both tests Processing work normally.

    I'd put a print screen with I'm using Mac with Unity don't working. I'm tried others ports and I'm tried with runs every at same local: Mac with Processing and Unity3D and PC with Unity3D and Processing.

    The other Script wich only send(with the error when try to open but send) I'm realized some tests with Processing and it works. But this don't received only send.


    Sorry for something and thanks for all!
    Hi,
    from your screenshots I can see that you are sending in processing to path '/test' (new OscMessage("/test")). But the c# address handlers you use have the paths "/1/toggle1" and "/2/toggle2". This has to match. So setting this to e.g. "/1/toggle1" in processing should make it work.

    Regards, Kai

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •