From b14d4d743bdf79cc8814fdf78bdf017a1ac3b8af Mon Sep 17 00:00:00 2001 From: dgflash Date: Sun, 28 Sep 2025 15:45:17 +0800 Subject: [PATCH] =?UTF-8?q?GameComponent=E6=B7=BB=E5=8A=A0loadAny=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/module/common/GameComponent.ts | 30 +++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/assets/module/common/GameComponent.ts b/assets/module/common/GameComponent.ts index dac129b..f2a030f 100644 --- a/assets/module/common/GameComponent.ts +++ b/assets/module/common/GameComponent.ts @@ -102,15 +102,6 @@ export class GameComponent extends Component { createPrefabNode(path: string, bundleName: string = oops.res.defaultBundleName): Node { return ViewUtil.createPrefabNode(path, bundleName); } - - /** - * 加载预制并创建预制节点 - * @param path 资源路径 - * @param bundleName 资源包名 - */ - createPrefabNodeAsync(path: string, bundleName: string = oops.res.defaultBundleName): Promise { - return ViewUtil.createPrefabNodeAsync(path, bundleName); - } //#endregion //#region 资源加载管理 @@ -194,9 +185,26 @@ export class GameComponent extends Component { * @param type 资源类型 * @param onProgress 加载进度回调 */ - load(bundleName: string, paths: Paths | AssetType, type?: AssetType | ProgressCallback, onProgress?: ProgressCallback) { + load(bundleName: string, paths: Paths | AssetType, type?: AssetType) { this.addPathToRecord(ResType.Load, bundleName, paths); - return oops.res.load(bundleName, paths, type, onProgress); + return oops.res.load(bundleName, paths, type); + } + + /** + * 加载指定资源包中的多个任意类型资源 + * @param bundleName 远程包名 + * @param paths 资源路径 + * @param onProgress 加载进度回调 + * @param onComplete 加载完成回调 + */ + loadAny(bundleName: string | string[], paths: string[] | ProgressCallback, onProgress?: ProgressCallback | CompleteCallback, onComplete?: CompleteCallback): void { + if (typeof bundleName === "string" && paths instanceof Array) { + this.addPathToRecord(ResType.Load, bundleName, paths); + } + else { + this.addPathToRecord(ResType.Load, resLoader.defaultBundleName, bundleName); + } + oops.res.loadAny(bundleName, paths, onProgress, onComplete); } /**