ialex32x / unity-jsb

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

Dictionary conversion with proxy and other conversion improvements #84

Closed KurtGokhan closed 2 years ago

KurtGokhan commented 2 years ago

Added a special conversion for all types deriving from IDictionary<string,object>, so that they can be treated as regular JS objects. There seemed to be no way to do this from outside, so I had to add it into source code. I had to improvise a bit at the part with the object identity. Because when proxy is passed back to C#, we want to get original dictionary.

Note that this is not tested for static codegen. It is also somewhat opinionated. Expecting your feedback.

Also added another conversion trick when converting to object. This was needed because structs don't get cached, so the js_get_cached_object does not return a value for them. But they also have a original C# object that can be converted to object.