cs-util-com / cscore

cscore is a minimal-footprint library providing commonly used helpers & patterns for your C# projects. It can be used in both pure C# and Unity projects.
https://cs-util-com.github.io/cscore/
Apache License 2.0
183 stars 31 forks source link

Browser Feature wrappers #88

Closed HtoTheB closed 11 months ago

HtoTheB commented 1 year ago

Unity provides lots of features in a platform-agnostic way. However there are several functionalities of a browser we can and need to exploit when running in the web (via WebGL).

We want to implement a couple of helper functions to access basic browser functionality from within unity without having to venture into the javascript world. The focus will lie on functions that are not provided by Unity for other build targets (i.e. browser history interaction, warning dialogs, etc.).

We have ventured into other features like getting the microphone working in the browser, but Unity already provides an API for that and we don't want to encourage people to writing platform-specific code, as it is the main benefit of using an engine in the first place.

How would we go about doing this? Our current plan would be to create a plugin in the unity package of the repository, including all of the scripts required (maybe append the readme with an example).

cs-util commented 1 year ago

Sounds like a great plan, my suggestion would be that you create a CsCoreUnityWebGl folder the same way we created the existing CsCoreUnity folder so that the code in the CsCoreUnityWebGl has both its own package.json and its own .asmdef file. This way any developer that wants to include the additional components in their WebGL application can do so and other non WebGL projects dont have to include them.

Both the package.json and .asmdef file you should be able to use the existing ones I linked as a starting point in case you didnt work with these before. Let me know if you have questions, I will review the PR once you created a first one.

HtoTheB commented 1 year ago

We've noticed that all of the templates that are included here: https://github.com/cs-util-com/cscore/tree/master/CsCore/UnityTests/Assets/WebGLTemplates are severely out of date. Unity now offers a fullscreen template (alongside a fullscreen template with an additional debug console) grafik So the folder is not needed anymore.

HtoTheB commented 1 year ago

So we have a few demo-scenes that we wanted to package together with the other demo scenes. However this leads to weird crossrefences from ASMDEFs that are for all platforms and a requirement for an assembly that is only for WebGL and so on... So for now we decided to package the demo scenes together with the module (it's only a few scenes and classes anyway) to avoid creating a huge mess with 2 new modules everywhere.

cs-util commented 1 year ago

Ok sounds good, feel free to create a PR if there is something that should already be reviewed