|
@@ -1,8 +1,7 @@
|
|
|
-import { _decorator, Asset, assetManager, AssetManager,Constructor, SpriteFrame} from 'cc';
|
|
|
+import { _decorator, Asset, assetManager, AssetManager,Constructor, Prefab, SpriteFrame} from 'cc';
|
|
|
import { Singleton } from './Singleton';
|
|
|
import { bundleConfig } from '../configs/BundleConfig';
|
|
|
import { Logger } from '../extend/Logger';
|
|
|
-
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
/** wws
|
|
@@ -15,6 +14,8 @@ export interface BundleAsset {
|
|
|
type?: Constructor<Asset>;
|
|
|
/** 是否跳过加载(默认false*/
|
|
|
skipLoading?: boolean;
|
|
|
+ /** 是否是目录(默认false)*/
|
|
|
+ isDirectory?: boolean;
|
|
|
}
|
|
|
|
|
|
/**Bundle 配置项*/
|
|
@@ -87,7 +88,6 @@ class BundleManager extends Singleton {
|
|
|
totalProgress: 0
|
|
|
};
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 加载配置bundle下的所有资源
|
|
|
* @param onProgress 加载的进度回调
|
|
@@ -109,24 +109,14 @@ class BundleManager extends Singleton {
|
|
|
});
|
|
|
*/
|
|
|
public async preloadConfigAllRes(
|
|
|
- onProgress?: ProgressCallback
|
|
|
+ onProgress?: ProgressCallback,
|
|
|
+ config: bundleConfig = bundleConfig
|
|
|
): Promise<void> {
|
|
|
//初始化Bundle配置
|
|
|
- bundleMgr.initConfig(bundleConfig);
|
|
|
- try {// 开始加载并显示进度
|
|
|
- await bundleMgr.loadLaunchBundles(onProgress);
|
|
|
- } catch (error) {
|
|
|
- Logger.error('资源加载失败:', error);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 初始化Bundle配置
|
|
|
- * @param settings Bundle配置表
|
|
|
- */
|
|
|
- public initConfig(settings: bundleConfig): void {
|
|
|
- this._settings = settings;
|
|
|
- this._calculateTotalSteps();
|
|
|
+ this._settings = config;
|
|
|
+ await this._calculateTotalSteps();
|
|
|
+ //开始加载并显示进度
|
|
|
+ await bundleMgr.loadLaunchBundles(onProgress);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -142,16 +132,93 @@ class BundleManager extends Singleton {
|
|
|
//顺序加载每个Bundle
|
|
|
for (const [bundleName, setting] of bundlesToLoad) {
|
|
|
this._loadProgress.currentBundle = bundleName;
|
|
|
- try {
|
|
|
- if(setting.autoLoadAll) {
|
|
|
- await this._loadAutoBundle(bundleName, setting, onProgress);
|
|
|
- }else if (setting.preloadAssets) {
|
|
|
- await this._loadConfiguredBundle(bundleName, setting.preloadAssets, onProgress);
|
|
|
+ if(setting.autoLoadAll) {
|
|
|
+ await this._loadAutoBundle(bundleName, setting, onProgress);
|
|
|
+ }else if (setting.preloadAssets) {
|
|
|
+ await this._loadConfiguredBundle(bundleName, setting.preloadAssets, onProgress);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async getBundleAssetList(bundleName: string): Promise<string[]> {
|
|
|
+ // 远程 Bundle 路径
|
|
|
+ const configUrl = `${bundleName}/config.json`;
|
|
|
+ // 使用原生 XMLHttpRequest 或 fetch 获取 config.json
|
|
|
+ const response = await fetch(configUrl);
|
|
|
+ const config = await response.json();
|
|
|
+
|
|
|
+ // 从 config.json 中提取资源路径
|
|
|
+ if (config && config.packages && config.packages[0] && config.packages[0].pathMap) {
|
|
|
+ return Object.keys(config.packages[0].pathMap);
|
|
|
+ }
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算总加载步骤数(用于进度计算)
|
|
|
+ */
|
|
|
+ private async _calculateTotalSteps(): Promise<void> {
|
|
|
+ let total = 0;
|
|
|
+ for (const [bundleName, setting] of this._settings) {
|
|
|
+ if(setting.loadAtLaunch){
|
|
|
+ const bundle = await this.getBundle(bundleName);
|
|
|
+ if(setting.autoLoadAll) {//整个bundle包下的资源
|
|
|
+ if(bundle && bundle['config']?.paths?._map) {
|
|
|
+ total += Object.keys(bundle['config'].paths._map).length;
|
|
|
+ }
|
|
|
+ }else if (setting.preloadAssets) {//只统计需要加载的资源(skipLoading=false的)
|
|
|
+ let pathsToLoad = await this._expandDirectoryAssets(bundle, setting.preloadAssets);
|
|
|
+ total += pathsToLoad.length;
|
|
|
}
|
|
|
- } catch (err) {
|
|
|
- Logger.error(`加载Bundle失败 [${bundleName}]:`, err);
|
|
|
}
|
|
|
}
|
|
|
+ this._loadProgress.totalSteps = total;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自动加载Bundle内所有资源
|
|
|
+ */
|
|
|
+ private async _loadAutoBundle(
|
|
|
+ bundleName: string,
|
|
|
+ setting: BundleSetting,
|
|
|
+ onProgress?: ProgressCallback
|
|
|
+ ): Promise<void> {
|
|
|
+ //1.加载Bundle
|
|
|
+ const bundle = await this.getBundle(bundleName);
|
|
|
+ //2.获取Bundle内所有资源路径 应用排除规则 应用排除规则
|
|
|
+ const assetPaths = await this._getBundleAssets(bundle, {
|
|
|
+ excludeExtensions: setting.excludeExtensions
|
|
|
+ });
|
|
|
+ let pathsToLoad = assetPaths.filter(path => !setting.excludePaths?.some(exclude => path.startsWith(exclude)));
|
|
|
+ //3.加载所有资源
|
|
|
+ await this._loadBundleAssets(
|
|
|
+ bundleName,
|
|
|
+ pathsToLoad.map(path => ({ path })),
|
|
|
+ onProgress
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据配置加载Bundle资源
|
|
|
+ */
|
|
|
+ private async _loadConfiguredBundle(
|
|
|
+ bundleName: string,
|
|
|
+ assets: BundleAsset[],
|
|
|
+ onProgress?: ProgressCallback
|
|
|
+ ): Promise<void> {
|
|
|
+ //加载Bundle 处理目录资源
|
|
|
+ const bundle = await this.getBundle(bundleName);
|
|
|
+ //一个bundle下的目录资源
|
|
|
+ let pathsToLoad = await this._expandDirectoryAssets(bundle, assets);
|
|
|
+ //加载资源
|
|
|
+ await this._loadBundleAssets(
|
|
|
+ bundleName,
|
|
|
+ pathsToLoad.map(asset => ({
|
|
|
+ path: asset.path,
|
|
|
+ ...(asset.type && { type: asset.type })
|
|
|
+ })),
|
|
|
+ onProgress
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -197,32 +264,27 @@ class BundleManager extends Singleton {
|
|
|
} = {}
|
|
|
): Promise<string[]> {
|
|
|
const { excludeFolders = true, excludeExtensions = [] } = options;
|
|
|
- try {
|
|
|
- let paths: string[] = [];
|
|
|
- //方法1:直接从配置的paths._map中获取所有键(路径)
|
|
|
- if(bundle['config']?.paths?._map) {//直接从配置的paths._map中获取所有键(路径)
|
|
|
- paths = Array.from(Object.keys(bundle['config'].paths._map));
|
|
|
- }else if (bundle['_assetMap']) {//方法2:兼容旧的_assetMap方式
|
|
|
- paths = Array.from(bundle['_assetMap'].keys());
|
|
|
- }else {//方法3:回退方案
|
|
|
- paths = bundle.getDirWithPath('').map(item => item.path);
|
|
|
- }
|
|
|
- //过滤处理 排除文件夹路径
|
|
|
- let result = paths;
|
|
|
- if(excludeFolders) {
|
|
|
- result = result.filter(p => !p.endsWith('/'));
|
|
|
- }
|
|
|
- //排除特定扩展名
|
|
|
- if (excludeExtensions?.length) {
|
|
|
- result = result.filter(p =>
|
|
|
- !excludeExtensions.some(ext => p.endsWith(ext))
|
|
|
- );
|
|
|
- }
|
|
|
- return result;
|
|
|
- } catch (error) {
|
|
|
- Logger.error(`获取Bundle资源路径失败:`, error);
|
|
|
- throw error;
|
|
|
+ let paths: string[] = [];
|
|
|
+ //方法1:直接从配置的paths._map中获取所有键(路径)
|
|
|
+ if(bundle['config']?.paths?._map) {//直接从配置的paths._map中获取所有键(路径)
|
|
|
+ paths = Array.from(Object.keys(bundle['config'].paths._map));
|
|
|
+ }else if (bundle['_assetMap']) {//方法2:兼容旧的_assetMap方式
|
|
|
+ paths = Array.from(bundle['_assetMap'].keys());
|
|
|
+ }else {//方法3:回退方案
|
|
|
+ paths = bundle.getDirWithPath('').map(item => item.path);
|
|
|
+ }
|
|
|
+ //过滤处理 排除文件夹路径
|
|
|
+ let result = paths;
|
|
|
+ if(excludeFolders) {
|
|
|
+ result = result.filter(p => !p.endsWith('/'));
|
|
|
}
|
|
|
+ //排除特定扩展名
|
|
|
+ if(excludeExtensions?.length) {
|
|
|
+ result = result.filter(p =>
|
|
|
+ !excludeExtensions.some(ext => p.endsWith(ext))
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -230,34 +292,41 @@ class BundleManager extends Singleton {
|
|
|
*/
|
|
|
private async _loadBundleAssets(
|
|
|
bundleName: string,
|
|
|
- bundle: AssetManager.Bundle,
|
|
|
assets: {path: string, type?: Constructor<Asset>}[],
|
|
|
onProgress?: ProgressCallback,
|
|
|
): Promise<void> {
|
|
|
const totalAssets = assets.length;
|
|
|
+ if (totalAssets == 0) return;
|
|
|
let loadedAssets = 0;
|
|
|
- //顺序加载每个资源(保持进度准确)
|
|
|
- for (const asset of assets) {
|
|
|
- await new Promise<void>((resolve) => {
|
|
|
- this.loadAsset(bundleName,asset.path, asset.type, (err) => {
|
|
|
- if(!err) {
|
|
|
- //更新进度状态
|
|
|
- loadedAssets++;
|
|
|
- this._loadProgress.completedSteps++;
|
|
|
- this._loadProgress.currentAsset = asset.path;
|
|
|
- this._loadProgress.bundleProgress = loadedAssets / totalAssets;
|
|
|
- //计算总进度(限制最大0.999避免提前显示100%)
|
|
|
- this._loadProgress.totalProgress = Math.min(
|
|
|
- this._loadProgress.completedSteps / this._loadProgress.totalSteps,
|
|
|
- 1
|
|
|
- );
|
|
|
- // 触发进度回调
|
|
|
- this._updateProgress(onProgress);
|
|
|
+ //创建所有资源的加载Promise数组
|
|
|
+ const loadPromises = assets.map(asset => {
|
|
|
+ return new Promise<void>((resolve, reject) => {
|
|
|
+ this.loadAsset(bundleName, asset.path, asset.type, (err) => {
|
|
|
+ if (err) {
|
|
|
+ Logger.error(`[${bundleName}] 加载资源失败: ${asset.path}`, err);
|
|
|
+ reject(err);
|
|
|
+ return;
|
|
|
}
|
|
|
+ loadedAssets++;
|
|
|
+ this._loadProgress.completedSteps++;
|
|
|
+ this._loadProgress.currentBundle = bundleName;
|
|
|
+ this._loadProgress.currentAsset = asset.path;
|
|
|
+ this._loadProgress.bundleProgress = loadedAssets / totalAssets;
|
|
|
+ this._loadProgress.totalProgress = Math.min(
|
|
|
+ this._loadProgress.completedSteps / this._loadProgress.totalSteps,
|
|
|
+ 1// 避免提前显示100%
|
|
|
+ );
|
|
|
+ this._updateProgress(onProgress);
|
|
|
resolve();
|
|
|
});
|
|
|
});
|
|
|
- }
|
|
|
+ });
|
|
|
+ //等待所有资源加载完成
|
|
|
+ await Promise.all(loadPromises)
|
|
|
+ .catch(err => {
|
|
|
+ Logger.error(`[${bundleName}] 部分资源加载失败`, err);
|
|
|
+ throw err; // 重新抛出错误让上层处理
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**调用事例
|
|
@@ -324,8 +393,8 @@ class BundleManager extends Singleton {
|
|
|
assetPath: string,
|
|
|
type: Constructor<T> | null,
|
|
|
onComplete?: (err: Error | null, asset?: T) => void
|
|
|
- ): Promise<T> | void {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
+ ): Promise<T | null> {
|
|
|
+ return new Promise <T | null>((resolve, reject) => {
|
|
|
const cacheKey = `${assetPath}`;
|
|
|
//从资源缓存中caches取
|
|
|
const cachedAsset = this._assetCache.get(cacheKey);
|
|
@@ -333,38 +402,39 @@ class BundleManager extends Singleton {
|
|
|
Logger.log(`[Cache Hit] Using cached asset: ${cacheKey}`);
|
|
|
onComplete?.(null, cachedAsset as T);
|
|
|
resolve(cachedAsset as T);
|
|
|
- return;
|
|
|
- }
|
|
|
- this.loadBundle(bundleName, (err, bundle) => {
|
|
|
- if (err) {
|
|
|
- onComplete?.(err);
|
|
|
- reject(null);
|
|
|
- return;
|
|
|
- }
|
|
|
- //特殊处理SpriteFrame的路径提示
|
|
|
- const isSpriteFrame = type && (type as any).name === 'SpriteFrame';
|
|
|
- if(isSpriteFrame && !assetPath.endsWith('/spriteFrame')) {
|
|
|
- Logger.warn(
|
|
|
- `SpriteFrame路径建议: ${assetPath} -> ${assetPath}/spriteFrame`,
|
|
|
- `\n(请确认是否使用完整SpriteFrame路径)`
|
|
|
- );
|
|
|
- }
|
|
|
- bundle!.load(assetPath, type,(err, asset) => {
|
|
|
- if(err || !asset) {
|
|
|
- Logger.error(`加载失败 [${bundleName}] ${assetPath}:`, err.message);
|
|
|
- const warning = isSpriteFrame
|
|
|
- ? `\n可能原因:\n1. 使用完整路径如 ${assetPath}/spriteFrame 类型为SpriteFrame\n2. 或者加载Texture: ${assetPath}/texture 类型为Texture`
|
|
|
- : `\n请检查资源路径是否正确`;
|
|
|
- Logger.warn(`空资源 [${bundleName}] ${assetPath}`, warning);
|
|
|
- reject(null);
|
|
|
- }else{
|
|
|
- this._assetCache.set(cacheKey, asset);
|
|
|
- resolve(asset);
|
|
|
+ }else{
|
|
|
+ this.loadBundle(bundleName, (err, bundle) => {
|
|
|
+ if (err) {
|
|
|
+ onComplete?.(err);
|
|
|
+ reject(err);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //特殊处理SpriteFrame的路径提示
|
|
|
+ const isSpriteFrame = type && (type as any).name === 'SpriteFrame';
|
|
|
+ if(isSpriteFrame && !assetPath.endsWith('/spriteFrame')) {
|
|
|
+ Logger.warn(
|
|
|
+ `SpriteFrame路径建议: ${assetPath} -> ${assetPath}/spriteFrame`,
|
|
|
+ `\n(请确认是否使用完整SpriteFrame路径)`
|
|
|
+ );
|
|
|
}
|
|
|
- onComplete?.(err, asset as T);
|
|
|
+ bundle!.load(assetPath, type,(err, asset) => {
|
|
|
+ if(err || !asset) {
|
|
|
+ Logger.error(`加载失败 [${bundleName}] ${assetPath}:`, err.message);
|
|
|
+ const warning = isSpriteFrame
|
|
|
+ ? `\n可能原因:\n1. 使用完整路径如 ${assetPath}/spriteFrame 类型为SpriteFrame\n2. 或者加载Texture: ${assetPath}/texture 类型为Texture`
|
|
|
+ : `\n请检查资源路径是否正确`;
|
|
|
+ Logger.warn(`空资源 [${bundleName}] ${assetPath}`, warning);
|
|
|
+ reject(err);
|
|
|
+ return;
|
|
|
+ }else{
|
|
|
+ this._assetCache.set(cacheKey, asset);
|
|
|
+ }
|
|
|
+ onComplete?.(err, asset as T);
|
|
|
+ resolve(asset as T);
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
- })
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -416,15 +486,7 @@ class BundleManager extends Singleton {
|
|
|
public hasBundle(bundleName: string): boolean {
|
|
|
return this._bundles.has(bundleName);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取Bundle的引用计数
|
|
|
- * @param bundleName Bundle名称
|
|
|
- */
|
|
|
- public getRefCount(bundleName: string): number {
|
|
|
- return this._bundles.get(bundleName)?.refCount || 0;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 释放所有Bundle
|
|
|
* @param force 是否强制释放
|
|
@@ -432,30 +494,53 @@ class BundleManager extends Singleton {
|
|
|
public releaseAll(force: boolean = false): void {
|
|
|
this._bundles.forEach((_, name) => this.releaseBundle(name, force));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- * 计算总加载步骤数(用于进度计算)
|
|
|
+ * 展开目录资源为具体资源列表
|
|
|
+ * @param bundle Bundle实例
|
|
|
+ * @param assets 原始资源列表
|
|
|
*/
|
|
|
- private _calculateTotalSteps(): void {
|
|
|
- let total = 0;
|
|
|
- this._settings.forEach((setting, bundleName) => {
|
|
|
- if(!setting.loadAtLaunch) return;
|
|
|
- if(setting.autoLoadAll) {
|
|
|
- //获取实际资源数量(需要先加载bundle)
|
|
|
- const bundle = this._bundles.get(bundleName)?.bundle;
|
|
|
- if (bundle && bundle['config']?.paths?._map) {
|
|
|
- total += Object.keys(bundle['config'].paths._map).length;
|
|
|
- } else {//自动加载模式先预估为1步,实际加载时会修正
|
|
|
- total += 1;
|
|
|
- }
|
|
|
- }else if (setting.preloadAssets) {
|
|
|
- //只统计需要加载的资源(skipLoading=false的)
|
|
|
- total += setting.preloadAssets.filter(asset => !asset.skipLoading).length;
|
|
|
+ private async _expandDirectoryAssets(
|
|
|
+ bundle: AssetManager.Bundle,
|
|
|
+ assets: BundleAsset[]
|
|
|
+ ): Promise<BundleAsset[]> {
|
|
|
+ let result: BundleAsset[] = [];
|
|
|
+ for(const asset of assets) {
|
|
|
+ if (!asset.isDirectory) {
|
|
|
+ result.push(asset);
|
|
|
+ }else{
|
|
|
+ //获取目录下所有资源路径
|
|
|
+ const dirPath = asset.path.endsWith('/') ? asset.path : `${asset.path}/`;
|
|
|
+ const allPaths = await this._getBundleAssets(bundle, {
|
|
|
+ excludeFolders: true,
|
|
|
+ excludeExtensions: ['.meta']
|
|
|
+ });
|
|
|
+ //筛选出该目录下的资源
|
|
|
+ const dirResources = allPaths.filter(path =>
|
|
|
+ path.startsWith(dirPath)
|
|
|
+ && !path.substring(dirPath.length).includes('/'));
|
|
|
+ //转换为资源配置
|
|
|
+ dirResources.forEach(path => {
|
|
|
+ result.push({
|
|
|
+ path,
|
|
|
+ skipLoading: false
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
- });
|
|
|
- this._loadProgress.totalSteps = total;
|
|
|
+ }
|
|
|
+ result = result.filter(asset => !asset.skipLoading);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 触发进度回调
|
|
|
+ */
|
|
|
+ private _updateProgress(onProgress?: ProgressCallback): void {
|
|
|
+ //传递进度状态的副本,避免外部修改
|
|
|
+ onProgress?.({...this._loadProgress});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 重置加载进度状态
|
|
|
*/
|
|
@@ -470,73 +555,7 @@ class BundleManager extends Singleton {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 自动加载Bundle内所有资源
|
|
|
- */
|
|
|
- private async _loadAutoBundle(
|
|
|
- bundleName: string,
|
|
|
- setting: BundleSetting,
|
|
|
- onProgress?: ProgressCallback
|
|
|
- ): Promise<void> {
|
|
|
- //1.加载Bundle
|
|
|
- const bundle: AssetManager.Bundle = await this.getBundle(bundleName);
|
|
|
- try {
|
|
|
- //2.获取Bundle内所有资源路径
|
|
|
- const assetPaths = await this._getBundleAssets(bundle, {
|
|
|
- excludeExtensions: setting.excludeExtensions
|
|
|
- });
|
|
|
- //3.应用排除规则
|
|
|
- const pathsToLoad = assetPaths.filter(path =>
|
|
|
- !setting.excludePaths?.some(exclude => path.startsWith(exclude))
|
|
|
- );
|
|
|
- //4.更新总步骤数(替换之前预估的1步)
|
|
|
- this._loadProgress.totalSteps += pathsToLoad.length - 1;
|
|
|
- this._updateProgress(onProgress);
|
|
|
- //5.加载所有资源
|
|
|
- await this._loadBundleAssets(
|
|
|
- bundleName,
|
|
|
- bundle,
|
|
|
- pathsToLoad.map(path => ({ path })),
|
|
|
- onProgress
|
|
|
- );
|
|
|
- } catch (err) {
|
|
|
- Logger.error(`扫描Bundle资源失败 [${bundleName}]:`, err);
|
|
|
- throw err;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据配置加载Bundle资源
|
|
|
- */
|
|
|
- private async _loadConfiguredBundle(
|
|
|
- bundleName: string,
|
|
|
- assets: BundleAsset[],
|
|
|
- onProgress?: ProgressCallback
|
|
|
- ): Promise<void> {
|
|
|
- //1.加载Bundle
|
|
|
- const bundle = await this.getBundle(bundleName);
|
|
|
- //2.过滤出需要加载的资源
|
|
|
- const assetsToLoad = assets.filter(asset => !asset.skipLoading);
|
|
|
- //3.加载资源
|
|
|
- await this._loadBundleAssets(
|
|
|
- bundleName,
|
|
|
- bundle,
|
|
|
- assetsToLoad.map(asset => ({
|
|
|
- path: asset.path,
|
|
|
- type: asset.type
|
|
|
- })),
|
|
|
- onProgress
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 触发进度回调
|
|
|
- */
|
|
|
- private _updateProgress(onProgress?: ProgressCallback): void {
|
|
|
- //传递进度状态的副本,避免外部修改
|
|
|
- onProgress?.({...this._loadProgress});
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 明确指定元组类型
|
|
|
* @param asset 未使用这个方法 之前在测试
|