Unity uses a tool called iotcp to compile .NET C Sharp code into C++. This tool handles stripping and massaging of .NET assemblies to reduce code size before generating C++ code, which is then compiled with Emscripten to produce WebAssembly.