Skip to content

[.NET] Add web export support #106125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

raulsntos
Copy link
Member

Use Mono embedding APIs statically linked to load the Mono WASM runtime.

  • The Mono runtime is fetched using the GetRuntimePack C# project. It needs the wasm-tools workload.
  • The GetRuntimePack defines stub functions for all the function pointers we need to retrieve from C#, so the PInvokeTableGenerator includes them in the generated pinvoke-table.h file.
  • Globalization doesn't work, so for now we're always enabling invariant mode.
  • The Mono runtime uses stubs for their exported JavaScript functions, these need to be replaced with the real implementation in their dotnet.runtime.js module but we don't have an easy way to do that yet, which means some BCL APIs will not work (i.e.: crypto APIs)
  • Closes Readd support for web platform exports when using the C# (.NET) version of the engine #70796

Warning

This is still a work in progress, but it should be possible to export a C# game to web with some manual changes to the exported .js afterwards.


This PR was tested with the demo project: Web .NET prototype

Note

The demo project requires multi-threading, so make sure to change the <WasmEnableThreads> property to true to use the right Mono runtime.

Use Mono embedding APIs statically linked to load the Mono WASM runtime.
@AIsht669
Copy link

AIsht669 commented May 7, 2025

This is awesome. Finally lets godot.net achieve web again

@WithinAmnesia
Copy link

WithinAmnesia commented May 8, 2025

@raulsntos Will this and other Godot C# full features run smoother in the long run as Godot 5.x? As in developing if Godot 4.x gets prototype C# features (such as web support) running and then in Godot 5.x it is optimized with the 'would be nice' features like size and security optimizations? I say this after reading your and the creative community's comments on the C# suite features and the prototype type work and potential for better solutions ( #70796 (comment) ).

I wonder this in order to better plan big projects (like a working vertical slice C# MIT Smooth Voxel MMORPG template for Godot) be it Godot 4.x and or Godot 5.x due to API and other complex team coordination which requires a stable software platform / game engine to first under take. If a Godot 5.x alpha with C# full features is being built soon (Godot 4.x may already be past its mid-life cycle once 4.5 is stable) it might be better for the 'power users' / big movers / proper game studios of the creative community to 'Wait for Godot' than to force teams of people to re-engine from Godot 4.x to Godot 5.x. Software long term stability is very critical for long term planning.

A lot of senior game studios are re-engining now and it is by default UE5 but personally I'd like it to be Godot also. A lot of studios are re-engining from the Unity implosion and I want Godot to succeed where Unity failed. Yet long term stability is very critical for the old grumblers of the industry.

Thus starting on a prototype Godot 5.x alpha with full C# features and optimizations and long term stability (and other details that require stability like Godot C# API issues being fully addressed) after ~Godot 4.5 stable is probably a practical way forward for the Godot creative community to keep both near future growth of Godot game engine progressing well and also keep Godot 4.x stable. Godot should get ready for the next gaming generation come 2027 / the late 2020's. Official Godot 5.x alpha plans for a feature roadmap can do a lot to also powerfully grow and future proof the Godot game engine creative community for today's and tomorrow's game building adventures.

It seems like Godot 4.x will get unified C# support as a GDextension and full C# parity support; yet this might be as prototype form. Once the Godot 4.x full C# features are operational this whole suite of C# features might require optimizations that are only properly done with seeing everything on the table first in working form and then in a big strong unified effort lead a proper engine rewrite to properly integrate the features to be optimized for being the best they can be. As from what can be currently done as the creative community for this console generation and the next console / gaming generation planned for 2027 / late 2020's with the PS6 / new Xbox / next gen consoles and gaming hardware.

The work of https://github.com/raulsntos and friends is very helpful to the creative community and I wish to thank the people involved greatly. This kind of work helps the creative community to make great games for everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Readd support for web platform exports when using the C# (.NET) version of the engine
3 participants