I like Unity and I like being able to play with the webcam as input. Unfortunately, Webcam support within Unity – in particular, webcam support in the browser plugin for Unity – isn’t really possible out of the box. I’ve written a (somewhat naive) implementation using the Aquiris u3dobject framework – click here to see it in action! (I should also warn you that it seems to be somewhat (read:extremely) unstable when the video stream is being passed through – On Windows it seems to run at 10fps at an absolute maximum with the video stream on, on Mac it fares even worse.. fun to see though!)
A guy at Doncaster College has managed to get a similar system up and running, although it doesn’t seem to work for people behind a proxy. (Any similarity between their solution and mine is because they’re both based on the Aquiris sample system. The Doncaster people seem to be using a localconnection to get the texture transferred, which sounds promising; Mine is just passing things through the web page, and transferring the pixel data in an extremely sub-optimal way. Each pixel’s value, for example Ox FF FF FF (white) is converted to the ASCII string “255:255:255″, passed through the JS and converted to Unity-native colour values (1.0f,1.0f,1.0f). It’s roundabout but I found that there were incompatibilities in the byte-array representations of bitmaps between Flash and Unity, and since the middle JS stage is created as a script, so the string has to be valid there too.
It’s still a far cry from the the totally direct form of Webcam input that appears to be possible with a commercial license – I’ll definitely be looking into how that one works. Even so, it represents a terrific way to leverage some of the functionality of Flash without having to re-create it in Unity – whether that functionality be webcam support or related to other aspects of Flash’s functionality like p2p network connections, microphone support or having a reasonable hook into local storage for a persistent session. I’m hoping to make good use of this bridge soon!