Closed 0xF6 closed 2 years ago
ScriptValue
is changed to sealed because it's better to ensure a unique mapping between JSValue and ScriptValue (but few code are not updated corresponding to this change yet)
If there are other concrete types inherited from ScriptValue
, ScriptFunction
as an example, there will be two mapping objects for a single JSValue simultaneously.
Okay, should I create a PR to fix at
https://github.com/ialex32x/unity-jsb/blob/67be3c1be8b94d9e6f213c6602ffc2b75d8a1c13/Packages/cc.starlessnight.unity-jsb/Source/Binding/Values_match.cs#L130
to be able to get ScriptValue
as an argument when calling a C# function from JS?
Of course, thanks a lot 👍
Im trying to get ScriptValue in custom methods when it calling in js. (ScriptFunction is work corretly, ScriptValue not)
I see this: https://github.com/ialex32x/unity-jsb/blob/67be3c1be8b94d9e6f213c6602ffc2b75d8a1c13/Packages/cc.starlessnight.unity-jsb/Source/Binding/Values_match.cs#L130 But
ScriptValue
is sealed and ctor is not public\protectedIt normal?
i try remove sealed and set ctor of ScriptValue as public, and try call from js C# fn:
And got expcetion in https://github.com/ialex32x/unity-jsb/blob/67be3c1be8b94d9e6f213c6602ffc2b75d8a1c13/Packages/cc.starlessnight.unity-jsb/Source/Binding/DynamicMethod.cs#L191 with message:
Object of type 'QuickJS.ScriptValue' cannot be converted to type 'Test.SampleObject '.'
Therefore https://github.com/ialex32x/unity-jsb/blob/67be3c1be8b94d9e6f213c6602ffc2b75d8a1c13/Packages/cc.starlessnight.unity-jsb/Source/Binding/Values_match.cs#L130 Is a incorrect, there should be
or (maybe need save check subClass, idk)