mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
* refine image asset auto releasing * refine
This commit is contained in:
@@ -36,6 +36,7 @@ import { assets, references } from './shared';
|
||||
import { legacyCC } from '../global-exports';
|
||||
import { ImageAsset } from '../assets/image-asset';
|
||||
import { TextureBase } from '../assets/texture-base';
|
||||
import { callInNextTick } from '../utils/misc';
|
||||
|
||||
function visitAsset (asset: Asset, deps: string[]) {
|
||||
// Skip assets generated programmatically or by user (e.g. label texture)
|
||||
@@ -210,14 +211,10 @@ class ReleaseManager {
|
||||
this._toDelete.add(asset._uuid, asset);
|
||||
if (!this._eventListener) {
|
||||
this._eventListener = true;
|
||||
legacyCC.director.once(legacyCC.Director.EVENT_AFTER_DRAW, this._freeAssets, this);
|
||||
callInNextTick(this._freeAssets.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
public removeFromDeleteQueue (asset: Asset): void {
|
||||
this._toDelete.remove(asset._uuid);
|
||||
}
|
||||
|
||||
private _freeAssets () {
|
||||
this._eventListener = false;
|
||||
this._toDelete.forEach((asset) => {
|
||||
|
||||
@@ -264,7 +264,6 @@ export class Asset extends Eventify(CCObject) {
|
||||
*/
|
||||
public addRef (): Asset {
|
||||
this._ref++;
|
||||
legacyCC.assetManager._releaseManager.removeFromDeleteQueue(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user