Text/Binary Streaming from WWW

Hey all,

Thanks in advance for the help.

We have a slightly different use case than most games. We have a service that dynamically generates motion data for a character which we display in 3D in the browser. The user is able to customize the motion and see it in almost real-time in the browser. We are evaluating using Unity web player as a replacement to our current 3D plugin.

In our current (non Unity) 3D plugin, when the user makes a change to the motion (using a UI on the web page), a HTTP request is sent to our servers, the motion is generated, and then the raw motion data is streamed back to the 3D plugin running on the client. We make heavy use of threads and binary streams which allow us to read each keyframe of the motion off the “wire” at a time without having to wait for the whole motion to download (which can be quite large depending on how long the motion is).

We are currently able to achieve streaming of the motion data (like YouTube) were we can start playing even if the whole motion isn’t downloaded yet.

Some leads that I’ve looked into to achieving this experience in Unity:

  • The WWW class I see in the Unity docs seems to make the data available only once completely downloaded.
  • Mono/.NET’s WebRequest class seemed promising, but it is disabled in the web player for obvious reasons.
  • I’ve not looked into AssetBundles yet, but I am not sure they would achive any streaming
  • I have read references to streaming on movie data, but I haven’t been able to turn that into a solution.

We are open to changing the format and way we stream the motion data to support Unity, but we very much want to keep as much of the “real-time” behavior as we can.

Thanks again. Any leads are appreciated.

You are basically right about all of this. AssetBundles are not likely to be of any help to you here.

One thing that springs to mind is that you can pass data between the Unity player and the web page using JavaScript functions (web JS, I mean). You can call a function in the page from Unity and call a Unity function from the page JavaScript. Would it be possible to handle the data transfer in the page JS (using Ajax or whatever) and then pass the data to the Unity player?

Streaming via Javascript was something I thought about but not something I ever tried.

Fortunately, one of our engineers here, Carl, gave it a try with some sample code here:

http://ajaxpatterns.org/HTTP_Streaming#Streaming_Wiki_Demo

It isn’t ideal, but the biggest problem is that compatibility may be dwindling.

http://plugins.jquery.com/project/ajax-http-stream

If we have any updates, we’ll post them here. Any other input is appreciated.

cheers,
eric