ialex32x / unity-jsb

It brings Javascript runtime capability to Unity3D by integrating QuickJS.
MIT License
335 stars 41 forks source link

Add native WebGL backend #91

Closed KurtGokhan closed 2 years ago

KurtGokhan commented 2 years ago

This is a JS engine backend for WebGL platform. It is implemented using Emscripten/Unity interoperability features. Implemented it in typescript, which can be built to generate the actual jslib file.

Will solve issues like #47

A live example of how it works can be seen here. https://reactunity.github.io/reference/material/dialogs

It is possible to debug the script code as this backend will show files under unity-jsb:// protocol.

image

~Currently there are some issues. There will be GC leaks in this version. I will fix this issue later. (Some API methods like SetPropertyInternal should automatically free values. I guess the GC issues are related to them. I don't know the full list of APIs that have this behavior. Will investigate.)~

I marked some API methods as TODO. I don't understand how they are supposed to work, so please comment if you have an idea of how to implement them. Also some API methods are not possible to implement.

Edit: I think all of the GC issues are fixed now. I don't have GC leaks in ReactUnity anymore even though it is doing a lot of interop.