unity
Untiy3D Asynchronous Sockets
There is a lot of discussion on whether you can use threading or asynchronous sockets with Unity3D and with the web player in particular.
I’ve created this sample project to demonstrate how this is done. You’ll see above that when you run it, the project attempts to make several asynchronous connections to web servers and download their default page.
There are a couple of basic things you should watch out for:
- Calls to Unity object or the UnityEngine API must be done on the main Unity application thread. You will need to martial values back to that thread. In this example, you’ll notice I don’t update the GUIText text value directly. I update my own internal status string and only update the GUIText during an Update( ) call.
- You need to shut down your socket and thread operations when OnApplicaitonQuit( ) is called. Exceptions may be thrown on any asychronous callback and you need to be sure to catch and handle these.
Search this Site
Follow me on Twitter
- Great cause, awesome games, pay what you want. RT @Wolfire: pay what you want for five awesome indie games http://bit.ly/9KASXz
- Thinking about writing a series on how to use #Lidgren with #Unity3d. I wrote an intro just to dip my toe in the water: http://bit.ly/drfJZs
- Tweaked the @bakedon web site a bit with a different template I customized slightly. What do you think? http://bit.ly/amEwRD
- Bwahahaha! It works! Need a demo...
- Powered byWordPress Twitter Widget Pro
Archives
- April 2010 (1)
- March 2010 (1)
- February 2010 (1)
- January 2010 (2)
- September 2009 (1)
- December 2008 (1)
- July 2008 (2)
- March 2008 (1)
- February 2008 (1)
- November 2007 (1)
- October 2007 (1)

