Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLR绑定和跨域继承适配器一起使用会导致对象被new两次 #763

Open
sagasarate opened this issue Aug 31, 2023 · 0 comments
Open

Comments

@sagasarate
Copy link

之前一直用1.67,最近升级了2.10,发现运行后unity里莫名多了很多gameobject,研究了下,发现新版生成的CLR绑定对构造函数也进行了绑定,如果这个类是有跨域继承的,并注册了跨域继承适配器,那么new对象的时候会new两次,先调用跨域继承适配器来生成对象,然后再调用CLR绑定函数new了一次对象,而且new的是原始类,并且这个new出来的对象被丢弃了,普通情况下就被垃圾回收了,但我用的类因为会创建gameobject,并且要手动dispose,结果就unity里挂了很多gameobject

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant