Tencent / puerts

PUER(普洱) Typescript. Let's write your game in UE or Unity with TypeScript.
Other
5.09k stars 709 forks source link

[Unity] 在PuertsV1.4预览版绑定System.Collections.Generic.List<自定义C#类>,导出后在安卓真机运行TS调用报错 必现 #918

Closed wuxiaoming1733 closed 2 years ago

wuxiaoming1733 commented 2 years ago

error log | 日志或报错信息

2022-07-19 16:48:43.374 29607-29690/? W/Unity: unhandledRejection,Error: c# exception:IL2CPP does not support marshaling delegates that point to generic methods. The generic method we're attemping to marshal is: PuertsStaticWrap.System_Collections_Generic_List_1_T__Wrap`1[[SweetSugar.Scripts.TargetScripts.TargetSystem.DropProbabilityContainer, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]::Constructor,stack: at Puerts.PuertsDLL.RegisterClass (System.IntPtr isolate, System.Int32 BaseTypeId, System.String fullName, Puerts.V8ConstructorCallback constructor, Puerts.V8DestructorCallback destructor, System.Int64 data) [0x00000] in <00000000000000000000000000000000>:0 at Puerts.TypeRegister.RegisterType (System.IntPtr isolate, System.Type type, System.Boolean includeNoPublic) [0x00000] in <00000000000000000000000000000000>:0 at Puerts.TypeRegister.GetTypeId (System.IntPtr isolate, System.Type type, System.Boolean& isFirst) [0x00000] in <00000000000000000000000000000000>:0 at Puerts.TypeRegister.GetTypeId (System.IntPtr isola

context | 编译/运行环境

Unity2018.4.36f android studio编译,真机华为手机运行

how to reproduce | 复现步骤

1.升级到最新版Puerts,使用Unity重新导出绑定TS类; 2.在puertconfig里面声明导出类,SweetSugar.Scripts.TargetScripts.TargetSystem.DropProbabilityContainer,为自定义C#类 puertconfig里面声明:

static IEnumerable<Type> Bindings
    {
        get
        {
            var list = new List<Type>()
            {

                typeof(System.Collections.Generic.List<SweetSugar.Scripts.TargetScripts.TargetSystem.DropProbabilityContainer>),

3.也添加了UsingAction声明: jsEnv.UsingAction(); 4.然后在TS里面调用这个C#List的时候就报错。

more | 其他

必现

throw-out commented 2 years ago

能不能提供一个示例工程, 包括具体的C#代码和ts代码. 这个报错没遇到过

wuxiaoming1733 commented 2 years ago

@zombieyang 他已经在Unity2018上复现。