mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
22 lines
550 B
JavaScript
22 lines
550 B
JavaScript
|
|
|
|
|
|
const oldDestroy = jsb.CCObject.prototype.destroy;
|
|
const oldDestroyImmediate = jsb.CCObject.prototype._destroyImmediate;
|
|
const deferredDestroyObjects = [];
|
|
|
|
jsb.CCObject.prototype.destroy = function() {
|
|
deferredDestroyObjects.push(this);
|
|
oldDestroy.call(this);
|
|
};
|
|
|
|
|
|
jsb.CCObject._deferredDestroyReleaseObjects = function() {
|
|
jsb.CCObject.deferredDestroy();
|
|
deferredDestroyObjects.length = 0;
|
|
};
|
|
|
|
jsb.CCObject.prototype._destroyImmediate = function() {
|
|
deferredDestroyObjects.push(this);
|
|
oldDestroyImmediate.call(this);
|
|
}; |