How Unity can work on Web if the code is written in C#? I understand that you can compile the C# code to a shared library and use it in Java (for Android) in ObjectiveC (for iOS) to enable Unity on multiple platforms, but you cant use shared library on JS. Does Unity do language to language translation from C# to JS to enable Unity on Web?

As I understand now starting from Unity 5.0 it even doesn't use Unity Web Player.


Unity Web Player, as you probably know, is a browser plugin so it is allowed to run anyway it likes.

Unity 5 will export to WebGL, and the article you linked says they worked with Mozilla to bring that technology, so they are most likely using Emscripten which is a LLVM to Javascript compiler. Several languages can be compiled to LLVM (including C# and Unity Script) so the proccess would be something like C# to LLVM to Javascript.

Some of the things that not supported currently:

  • Runtime generation of Substance textures
  • MovieTextures
  • Networking other then WWW class (a WebSockets plug-in is available)
  • Support for WebCam and Microphone access
  • Hardware cursor support
  • Most of the non-basic audio features
  • Script debugging
  • Threads
  • Any .NET features requiring dynamic code generation

You can read more about this technology on their blog.

  • 1
    \$\begingroup\$ Your blog link is more complete than the question's srticle, so there's no need to use speculative language (see the "Technical Details" section of the blog article). Unity 5 DOES use Emscripten. It compiles .NET bytecode into equivalent c++ source (with proprietary tech), and compiles that to asm.js. Unity's non-script code is c and c++, which they compile directly in the same way. \$\endgroup\$ Oct 28 '14 at 13:31
  • \$\begingroup\$ blogs.unity3d.com/2014/04/29/… you are completely right! That's why after so many translations they have performance problems as they confess: blogs.unity3d.com/2014/05/20/the-future-of-scripting-in-unity \$\endgroup\$
    – Narek
    Oct 28 '14 at 13:34

From the link you pasted we can read:

Helgason puts it this way: "We're coming into a world where some browsers will not support the [Unity] plugin, but some browsers will not support WebGL. Us having both means you can cover every browser."

Unity has spent two years working closely with Mozilla to ready this technology, which is being demoed live at GDC in both Firefox and Google Chrome browsers.

So since there is just a plugin I see no reason to use JavaScript but I'm not sure how entirely Unity Web Player is done. Wikipedia says it's C# and C++.

The other fact is that translation of Java into JavaScript is rather popular in LibGdx and PlayN thanks to Google Web Toolkit so it's possible.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .