Files
cocos4/platforms/native/engine/jsb-object.js
T
2022-01-11 17:30:18 +08:00

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);
};