58 points · by robin_reala · 12y ago · 23 comments
> To convert the .NET game code (your C# and UnityScript scripts) into JavaScript, we developed a new technology in-house which we call IL2CPP. IL2CPP takes .NET bytecode and converts it to corresponding C++ source files, which we can then compile using any C++ compiler — such as emscripten to get your scripts converted to JavaScript. Expect more information on IL2CPP soon.
This however ... It's cool that it works.
But do we really have to compile C# to IL bytecode to CPP source to LLVM IR to asm.js javascript which the browser will compile to native code.
Just... I'm kinda speechless, not that this is possible, but viable for release.
Well the demos show it is. Still.
I guess you're saying that it sounds like a convoluted process? There are other ways to run C# on the web, like JSIL which compiles C# more directly to JS. In practice each approach has benefits and disadvantages.
But I wouldn't say that C# to IL to C++ to LLVM to asm.js to native is convoluted. It reuses a lot of existing tools (LLVM, Emscripten), and makes a lot of sense: Once you have C# to C++, you can compile that on any C++ compiler, including platforms where you couldn't run the Mono VM. C++ is as portable as it gets.
Why not just let us write to the C++ API ???
It seems .... circuitous. And I don't like the debugging implications at all.
The fear was Apple would ban mono AOT as well. During that time they were going to go C++. I wonder what would have happened.
Now that UE4 is pure C++ it does have that. C# is great and you can accomplish most things with plugins via C/C++/Obj-C/Java but having the pure C++ option would be killer. Then it would be a much easier jump into final form for WebGL/asm.js/etc.
Unity also has the Mono 2.x runtime and hasn't updated Xamarin licenses to go to mono 4. I wonder if they would be smart to jump to a C++ api at some point that could still use C# scripting possibly but goes to this lower level C++ form. It is hard with such a large userbase to jump to C++ but in 2010 they almost did.
In theory you can use the browser dev tools, and emscripten can emit source maps which helps. But the Unity editor is probably a far better experience for this use case.
To convert the .NET game code (your C# and UnityScript scripts) into JavaScript, we developed a new technology in-house which we call IL2CPP. IL2CPP takes .NET bytecode and converts it to corresponding C++ source files, which we can then compile using any C++ compiler — such as emscripten to get your scripts converted to JavaScript. Expect more information on IL2CPP soon.
...and how to fork it, ideally?
I hope Unity3d will follow Microsoft and partner with Xamarin. They wouldn't be in business without Mono - time to give back to the community.
Longer term, however, we expect that the performance and feature gap between the Web Player and WebGL will become much more narrow, and we expect that browser vendors will make the Web Player obsolete by dropping support for plug-ins, at which point WebGL will become the prime solution for targeting the web with Unity.