From 24c8596a55503322c2a2f939fd9ed52801e8fa42 Mon Sep 17 00:00:00 2001 From: dgflash Date: Wed, 15 Oct 2025 09:33:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8A=A0=E8=BD=BD=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/core/common/loader/ResLoader.ts | 27 +++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/assets/core/common/loader/ResLoader.ts b/assets/core/common/loader/ResLoader.ts index 64b66ed..67f7c1d 100644 --- a/assets/core/common/loader/ResLoader.ts +++ b/assets/core/common/loader/ResLoader.ts @@ -336,7 +336,7 @@ export class ResLoader { if (bundle) { const asset = bundle.get(path); if (asset) { - this.releasePrefabtDepsRecursively(bundleName, asset); + this.releasePrefabtDepsRecursively(asset); } } } @@ -354,7 +354,7 @@ export class ResLoader { var infos = bundle.getDirWithPath(path); if (infos) { infos.map((info) => { - this.releasePrefabtDepsRecursively(bundleName, info.uuid); + this.releasePrefabtDepsRecursively(info.uuid); }); } @@ -378,20 +378,25 @@ export class ResLoader { } /** 释放预制依赖资源 */ - private releasePrefabtDepsRecursively(bundleName: string, uuid: string | Asset) { + private releasePrefabtDepsRecursively(uuid: string | Asset) { + let asset: Asset | null | undefined; if (uuid instanceof Asset) { + asset = uuid; uuid.decRef(); - // assetManager.releaseAsset(uuid); - // this.debugLogReleasedAsset(bundleName, uuid); } else { - const asset = assetManager.assets.get(uuid); - if (asset) { - asset.decRef(); - // assetManager.releaseAsset(asset); - // this.debugLogReleasedAsset(bundleName, asset); - } + asset = assetManager.assets.get(uuid); + if (asset) asset.decRef(); } + + // 释放预制引用资源 + // if (asset instanceof Prefab) { + // const uuids: string[] = assetManager.dependUtil.getDepsRecursively(asset.uuid)!; + // uuids.forEach(uuid => { + // const asset = assetManager.assets.get(uuid); + // if (asset) asset.decRef(); + // }); + // } } /**