Unity destructor Or OnDestory

In 99% of all cases you don't want to use a destructor (finalizer) at all:

http://stackoverflow.com/questions/3649066/use-of-destructor-in-c
http://blog.stephencleary.com/2009/08/how-to-implement-idisposable-and.html

The destructor is called by the garbage collector which runs on a different thread. Custom managed classes never ever use a destructor unless you have unmanaged resources which need to be cleaned up. Never rely on a destructor to do something which should be in a manually called method. The destructor / finalizer in C# has nothing to do with a destructor in C++.

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页