Unity destructor Or OnDestory

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


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官方博客 返回首页