a3ceb9baa9ec92dce895d8c30568a194aeb574e7.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, assetManager, SpriteFrame, Singleton, bundleConfig, _dec, _class, _crd, ccclass, property, BundleManager, bundleMgr;
  4. function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  5. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  6. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  7. function _reportPossibleCrUseOfSingleton(extras) {
  8. _reporterNs.report("Singleton", "./Singleton", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfbundleConfig(extras) {
  11. _reporterNs.report("bundleConfig", "../configs/BundleConfig", _context.meta, extras);
  12. }
  13. return {
  14. setters: [function (_unresolved_) {
  15. _reporterNs = _unresolved_;
  16. }, function (_cc) {
  17. _cclegacy = _cc.cclegacy;
  18. __checkObsolete__ = _cc.__checkObsolete__;
  19. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  20. _decorator = _cc._decorator;
  21. assetManager = _cc.assetManager;
  22. SpriteFrame = _cc.SpriteFrame;
  23. }, function (_unresolved_2) {
  24. Singleton = _unresolved_2.Singleton;
  25. }, function (_unresolved_3) {
  26. bundleConfig = _unresolved_3.bundleConfig;
  27. }],
  28. execute: function () {
  29. _crd = true;
  30. _cclegacy._RF.push({}, "1fa75BNI1pLj673iR8sywfM", "BundleManager", undefined);
  31. __checkObsolete__(['_decorator', 'Asset', 'assetManager', 'AssetManager', 'Constructor', 'SpriteFrame']);
  32. ({
  33. ccclass,
  34. property
  35. } = _decorator);
  36. /** wws
  37. * Bundle 中的单个资源定义
  38. */
  39. /** wws
  40. * Bundle 中的单个资源定义
  41. */
  42. /**Bundle 配置项*/
  43. /**Bundle 配置表类型(Map结构) Key: Bundle名称 Value: Bundle配置*/
  44. /**加载进度信息*/
  45. /**
  46. * 进度回调函数类型
  47. * @param progress 当前加载进度信息
  48. */
  49. /**
  50. * 调用实例
  51. * bundleMgr.preloadConfigAllRes((progress) => {
  52. const percent = Math.floor(progress.totalProgress * 100);
  53. this.loadUI.progressLabel.string = `加载进度: ${percent}%`;
  54. this.loadUI.tipLabel.string = `${progress.currentBundle} (${progress.completedSteps}/${progress.totalSteps})`;
  55. // 更新进度条
  56. this.progressBar.progress = progress.totalProgress;
  57. this.progressBar.progress = progress.bundleProgress;
  58. //调试信息(可选)
  59. Logger.log(`当前加载: ${progress.currentAsset}`);
  60. });
  61. */
  62. BundleManager = (_dec = ccclass('BundleManager'), _dec(_class = class BundleManager extends (_crd && Singleton === void 0 ? (_reportPossibleCrUseOfSingleton({
  63. error: Error()
  64. }), Singleton) : Singleton) {
  65. constructor() {
  66. super(...arguments);
  67. //已加载的Bundle缓存(包含引用计数)
  68. this._bundles = new Map();
  69. //资源结果缓存cache (path -> asset)
  70. this._assetCache = new Map();
  71. //Bundle配置表
  72. this._settings = new Map();
  73. //当前加载进度状态
  74. this._loadProgress = {
  75. totalSteps: 0,
  76. completedSteps: 0,
  77. currentBundle: '',
  78. currentAsset: '',
  79. bundleProgress: 0,
  80. totalProgress: 0
  81. };
  82. }
  83. /**
  84. * 加载配置bundle下的所有资源
  85. * @param onProgress 加载的进度回调
  86. * @example 调用事例:
  87. bundleMgr.preloadConfigAllRes((progress) => {
  88. //更新UI进度显示
  89. const percent = Math.floor(progress.totalProgress * 100);
  90. this.loadUI.progressLabel.string = `加载进度: ${percent}%`;
  91. this.loadUI.tipLabel.string = `${progress.currentBundle} | ${progress.currentAsset}
  92. (${progress.completedSteps}/${progress.totalSteps})`;
  93. //更新进度条
  94. this.progressBar.progress = progress.totalProgress;
  95. //this.progressBar.progress = progress.bundleProgress;
  96. //调试信息(可选)
  97. Logger.log(`当前加载: ${progress.currentBundle}` + `${progress.currentAsset}`);
  98. if(progress.totalProgress == 1){
  99. this.loadComplete = true;
  100. }
  101. });
  102. */
  103. preloadConfigAllRes(onProgress, config) {
  104. var _this = this;
  105. return _asyncToGenerator(function* () {
  106. if (config === void 0) {
  107. config = _crd && bundleConfig === void 0 ? (_reportPossibleCrUseOfbundleConfig({
  108. error: Error()
  109. }), bundleConfig) : bundleConfig;
  110. }
  111. //初始化Bundle配置
  112. _this._settings = config;
  113. yield _this._calculateTotalSteps(); //开始加载并显示进度
  114. yield bundleMgr.loadLaunchBundles(onProgress);
  115. })();
  116. }
  117. /**
  118. * 加载启动时必须的Bundle(根据配置表中loadAtLaunch=true的配置)
  119. * @param onProgress 进度回调函数(可选)
  120. */
  121. loadLaunchBundles(onProgress) {
  122. var _this2 = this;
  123. return _asyncToGenerator(function* () {
  124. //重置进度状态
  125. _this2._resetProgress(); //获取需要加载的Bundle配置
  126. var bundlesToLoad = Array.from(_this2._settings.entries()).filter(_ref => {
  127. var [_, setting] = _ref;
  128. return setting.loadAtLaunch;
  129. }); //顺序加载每个Bundle
  130. for (var [bundleName, setting] of bundlesToLoad) {
  131. _this2._loadProgress.currentBundle = bundleName;
  132. if (setting != null && setting.autoLoadAll) {
  133. yield _this2._loadAutoBundle(bundleName, setting, onProgress);
  134. } else if (setting != null && setting.preloadAssets) {
  135. yield _this2._loadConfiguredBundle(bundleName, setting.preloadAssets, onProgress);
  136. }
  137. }
  138. })();
  139. }
  140. getBundleAssetList(bundleName) {
  141. return _asyncToGenerator(function* () {
  142. // 远程 Bundle 路径
  143. var configUrl = bundleName + "/config.json"; // 使用原生 XMLHttpRequest 或 fetch 获取 config.json
  144. var response = yield fetch(configUrl);
  145. var config = yield response.json(); // 从 config.json 中提取资源路径
  146. if (config && config.packages && config.packages[0] && config.packages[0].pathMap) {
  147. return Object.keys(config.packages[0].pathMap);
  148. }
  149. return [];
  150. })();
  151. }
  152. /**
  153. * 计算总加载步骤数(用于进度计算)
  154. */
  155. _calculateTotalSteps() {
  156. var _this3 = this;
  157. return _asyncToGenerator(function* () {
  158. var total = 0;
  159. for (var [bundleName, setting] of _this3._settings) {
  160. if (setting != null && setting.loadAtLaunch) {
  161. var _bundle = yield _this3.getBundle(bundleName);
  162. if (setting != null && setting.autoLoadAll) {
  163. var _bundle$config;
  164. //整个bundle包下的资源
  165. if (_bundle && (_bundle$config = _bundle['config']) != null && (_bundle$config = _bundle$config.paths) != null && _bundle$config._map) {
  166. total += Object.keys(_bundle['config'].paths._map).length;
  167. }
  168. } else if (setting != null && setting.preloadAssets) {
  169. //只统计需要加载的资源(skipLoading=false的)
  170. var pathsToLoad = yield _this3._expandDirectoryAssets(_bundle, setting.preloadAssets);
  171. total += pathsToLoad.length;
  172. }
  173. }
  174. }
  175. _this3._loadProgress.totalSteps = total;
  176. })();
  177. }
  178. /**
  179. * 自动加载Bundle内所有资源
  180. */
  181. _loadAutoBundle(bundleName, setting, onProgress) {
  182. var _this4 = this;
  183. return _asyncToGenerator(function* () {
  184. //加载Bundle
  185. var bundle = yield _this4.getBundle(bundleName); //获取Bundle内所有资源路径(带类型信息)
  186. var assets = yield _this4._getBundleAssets(bundle, {
  187. excludeExtensions: setting.excludeExtensions
  188. }); //过滤时使用资源的path字段
  189. var filteredAssets = assets.filter(asset => {
  190. var _setting$excludePaths;
  191. return !((_setting$excludePaths = setting.excludePaths) != null && _setting$excludePaths.some(exclude => asset.path.startsWith(exclude)));
  192. }); //直接传递完整资源对象(包含path和type)
  193. yield _this4._loadBundleAssets(bundleName, filteredAssets, // 直接传递完整资源对象
  194. onProgress);
  195. })();
  196. }
  197. /**
  198. * 根据配置加载Bundle资源
  199. */
  200. _loadConfiguredBundle(bundleName, assets, onProgress) {
  201. var _this5 = this;
  202. return _asyncToGenerator(function* () {
  203. //加载Bundle 处理目录资源
  204. var bundle = yield _this5.getBundle(bundleName); //一个bundle下的目录资源
  205. var pathsToLoad = yield _this5._expandDirectoryAssets(bundle, assets); //加载资源
  206. yield _this5._loadBundleAssets(bundleName, pathsToLoad.map(asset => _extends({
  207. path: asset.path
  208. }, asset.type && {
  209. type: asset.type
  210. })), onProgress);
  211. })();
  212. }
  213. /**
  214. * 加载指定Bundle
  215. * @param bundleName Bundle名称
  216. * @param onComplete 加载完成回调
  217. */
  218. loadBundle(bundleName, onComplete) {
  219. //检查是否已加载
  220. var bundleInfo = this._bundles.get(bundleName);
  221. if (bundleInfo) {
  222. bundleInfo.refCount++;
  223. onComplete == null || onComplete(null, bundleInfo.bundle);
  224. return;
  225. } //加载新Bundle
  226. assetManager.loadBundle(bundleName, (err, bundle) => {
  227. if (err) {
  228. console.error("\u52A0\u8F7DBundle\u5931\u8D25 [" + bundleName + "]:", err);
  229. onComplete == null || onComplete(err);
  230. return;
  231. } //缓存Bundle并设置引用计数
  232. this._bundles.set(bundleName, {
  233. bundle: bundle,
  234. refCount: 1
  235. });
  236. onComplete == null || onComplete(null, bundle);
  237. });
  238. }
  239. /**
  240. * 获取Bundle内资源路径列表
  241. */
  242. _getBundleAssets(bundle, options) {
  243. var _bundle$_config;
  244. if (options === void 0) {
  245. options = {};
  246. }
  247. var {
  248. excludeFolders = true,
  249. excludeExtensions = []
  250. } = options;
  251. var assets = []; //更安全的类型断言和路径过滤
  252. var pathMap = (_bundle$_config = bundle['_config']) == null || (_bundle$_config = _bundle$_config.assetInfos) == null ? void 0 : _bundle$_config._map;
  253. if (pathMap) {
  254. //过滤无效路径和带的衍生资源
  255. Object.values(pathMap).forEach(info => {
  256. if (info.path && !info.path.includes('@')) {
  257. assets.push({
  258. path: info.path,
  259. type: info.ctor
  260. });
  261. }
  262. });
  263. } //过滤处理 排除文件夹路径
  264. var result = assets.filter(asset => {
  265. //排除文件夹
  266. if (excludeFolders && asset.path.endsWith('/')) return false; //排除指定扩展名
  267. if (excludeExtensions != null && excludeExtensions.length && excludeExtensions.some(ext => asset.path.endsWith(ext))) return false;
  268. return true;
  269. });
  270. return result;
  271. }
  272. /**
  273. * 加载Bundle内的多个资源
  274. */
  275. _loadBundleAssets(bundleName, assets, onProgress) {
  276. var _this6 = this;
  277. return _asyncToGenerator(function* () {
  278. var totalAssets = assets.length;
  279. if (totalAssets == 0) return;
  280. var loadedAssets = 0; //创建所有资源的加载Promise数组
  281. var loadPromises = assets.map(asset => {
  282. return new Promise((resolve, reject) => {
  283. _this6.loadAsset(bundleName, asset.path, asset.type, err => {
  284. if (err) {
  285. console.error("[" + bundleName + "] \u52A0\u8F7D\u8D44\u6E90\u5931\u8D25: " + asset.path, err);
  286. reject(err);
  287. return;
  288. }
  289. loadedAssets++;
  290. _this6._loadProgress.completedSteps++;
  291. _this6._loadProgress.currentBundle = bundleName;
  292. _this6._loadProgress.currentAsset = asset.path;
  293. _this6._loadProgress.bundleProgress = loadedAssets / totalAssets;
  294. _this6._loadProgress.totalProgress = Math.min(_this6._loadProgress.completedSteps / _this6._loadProgress.totalSteps, 1 // 避免提前显示100%
  295. );
  296. _this6._updateProgress(onProgress);
  297. resolve();
  298. });
  299. });
  300. }); //等待所有资源加载完成
  301. yield Promise.all(loadPromises).catch(err => {
  302. console.error("[" + bundleName + "] \u90E8\u5206\u8D44\u6E90\u52A0\u8F7D\u5931\u8D25", err);
  303. throw err; // 重新抛出错误让上层处理
  304. });
  305. })();
  306. }
  307. /**调用事例
  308. await this.loadMultipleAssets("levels",
  309. [{ path: "map", type: Prefab },
  310. { path: "textures/trees", type: SpriteFrame },
  311. ],
  312. (progress) => {//直接更新UI进度条(0~1)
  313. this.loadingBar.progress = progress;
  314. }
  315. (err, asset, path) => {
  316. if (err) {
  317. Logger.error(`资源 ${path} 加载失败:`, err);
  318. } else {
  319. Logger.log(`资源 ${path} 加载成功:`, asset);
  320. }
  321. }
  322. );
  323. * 加载Bundle内的多个资源(仅计算当前Bundle的进度)
  324. * @param bundleName Bundle名称
  325. * @param assets 资源列表
  326. * @param onProgress 进度回调(当前Bundle的进度,范围0~1)
  327. */
  328. loadMultipleAssets(bundleName, assets, onProgress, onComplete) {
  329. var _this7 = this;
  330. return _asyncToGenerator(function* () {
  331. var totalAssets = assets.length;
  332. var loadedAssets = 0;
  333. var _loop = function* _loop(_asset) {
  334. yield new Promise(resolve => {
  335. _this7.loadAsset(bundleName, _asset.path, _asset.type, (err, loadedAsset) => {
  336. if (err) {
  337. console.error("\u52A0\u8F7D\u8D44\u6E90\u5931\u8D25 [" + bundleName + "] " + _asset.path + ":", err);
  338. onComplete == null || onComplete(err, undefined, _asset.path);
  339. } else {
  340. loadedAssets++;
  341. var bundleProgress = loadedAssets / totalAssets;
  342. onProgress == null || onProgress(bundleProgress);
  343. onComplete == null || onComplete(null, loadedAsset, _asset.path);
  344. }
  345. resolve();
  346. });
  347. });
  348. };
  349. for (var _asset of assets) {
  350. yield* _loop(_asset);
  351. }
  352. })();
  353. }
  354. /**调用事例
  355. await bundleMgr.loadAsset(bundleName,path,AudioClip,(err: Error, clip: AudioClip) => {
  356. if(err) {
  357. Logger.error("加载资源失败:", err);
  358. return;
  359. }});
  360. * 加载Bundle内的指定资源
  361. * @param bundleName Bundle名称
  362. * @param assetPath 资源路径
  363. * @param type 资源类型(可选)
  364. * @param onComplete 加载完成回调
  365. */
  366. loadAsset(bundleName, assetPath, type, onComplete) {
  367. var cacheKey = assetPath + "-" + (type == null ? void 0 : type.name); //从资源缓存中caches取
  368. var cachedAsset = this._assetCache.get(cacheKey);
  369. if (cachedAsset) {
  370. //console.log(`[Cache Hit] Using cached asset: ${cacheKey}`);
  371. onComplete == null || onComplete(null, cachedAsset);
  372. return Promise.resolve(cachedAsset);
  373. }
  374. return new Promise((resolve, reject) => {
  375. this.loadBundle(bundleName, (err, bundle) => {
  376. if (err) {
  377. onComplete == null || onComplete(err);
  378. reject(err);
  379. return;
  380. } //特殊处理SpriteFrame的路径提示
  381. var isSpriteFrame = type && type.name === 'SpriteFrame';
  382. if (isSpriteFrame && !assetPath.endsWith('/spriteFrame')) {
  383. console.warn("SpriteFrame\u8DEF\u5F84\u5EFA\u8BAE: " + assetPath + " -> " + assetPath + "/spriteFrame", "\n(\u8BF7\u786E\u8BA4\u662F\u5426\u4F7F\u7528\u5B8C\u6574SpriteFrame\u8DEF\u5F84)");
  384. }
  385. bundle.load(assetPath, type, (err, asset) => {
  386. if (err || !asset) {
  387. console.error("\u52A0\u8F7D\u5931\u8D25 [" + bundleName + "] " + assetPath + ":", err.message);
  388. var warning = isSpriteFrame ? "\n\u53EF\u80FD\u539F\u56E0:\n1. \u4F7F\u7528\u5B8C\u6574\u8DEF\u5F84\u5982 " + assetPath + "/spriteFrame \u7C7B\u578B\u4E3ASpriteFrame\n2. \u6216\u8005\u52A0\u8F7DTexture: " + assetPath + "/texture \u7C7B\u578B\u4E3ATexture" : "\n\u8BF7\u68C0\u67E5\u8D44\u6E90\u8DEF\u5F84\u662F\u5426\u6B63\u786E";
  389. console.warn("\u7A7A\u8D44\u6E90 [" + bundleName + "] " + assetPath, warning);
  390. onComplete == null || onComplete(err);
  391. reject(err != null ? err : new Error("Asset is null"));
  392. return;
  393. }
  394. this._assetCache.set(cacheKey, asset);
  395. console.log("\u52A0\u8F7D\u8D44\u6E90 " + assetPath + " \u6210\u529F: " + cacheKey + " + \u7C7B\u578B\u4E3A: " + (asset == null ? void 0 : asset.constructor.name));
  396. onComplete == null || onComplete(err, asset);
  397. resolve(asset);
  398. });
  399. });
  400. });
  401. }
  402. /**
  403. * 释放Bundle
  404. * @param bundleName Bundle名称
  405. * @param force 是否强制释放(即使还有引用)
  406. */
  407. releaseBundle(bundleName, force) {
  408. if (force === void 0) {
  409. force = false;
  410. }
  411. var bundleInfo = this._bundles.get(bundleName);
  412. if (!bundleInfo) return; //减少引用计数
  413. bundleInfo.refCount--; // 当引用计数归零或强制释放时
  414. if (bundleInfo.refCount <= 0 || force) {
  415. assetManager.removeBundle(bundleInfo.bundle);
  416. this._bundles.delete(bundleName);
  417. console.log("\u5DF2\u91CA\u653EBundle: " + bundleName);
  418. }
  419. }
  420. /**
  421. * 获取已加载的Bundle实例
  422. * @param bundleName Bundle名称
  423. * @returns Bundle实例或null
  424. */
  425. getBundle(bundleName) {
  426. var _this8 = this;
  427. return _asyncToGenerator(function* () {
  428. var _this8$_bundles$get;
  429. //先从缓存中查找
  430. var cachedBundle = (_this8$_bundles$get = _this8._bundles.get(bundleName)) == null ? void 0 : _this8$_bundles$get.bundle;
  431. if (cachedBundle) {
  432. return cachedBundle;
  433. }
  434. try {
  435. //如果缓存中没有,则加载bundle
  436. var _bundle2 = yield new Promise((resolve, reject) => {
  437. assetManager.loadBundle(bundleName, (err, bundle) => {
  438. err ? reject(err) : resolve(bundle);
  439. });
  440. });
  441. return _bundle2;
  442. } catch (error) {
  443. console.error("\u52A0\u8F7DBundle " + bundleName + " \u5931\u8D25:", error);
  444. return null;
  445. }
  446. })();
  447. }
  448. /**
  449. * 检查Bundle是否已加载
  450. * @param bundleName Bundle名称
  451. */
  452. hasBundle(bundleName) {
  453. return this._bundles.has(bundleName);
  454. }
  455. /**
  456. * 释放所有Bundle
  457. * @param force 是否强制释放
  458. */
  459. releaseAll(force) {
  460. if (force === void 0) {
  461. force = false;
  462. }
  463. this._bundles.forEach((_, name) => this.releaseBundle(name, force));
  464. }
  465. /**
  466. * 展开目录资源为具体资源列表
  467. * @param bundle Bundle实例
  468. * @param assets 原始资源列表
  469. */
  470. _expandDirectoryAssets(bundle, assets) {
  471. var _this9 = this;
  472. return _asyncToGenerator(function* () {
  473. var result = [];
  474. var _loop2 = function* _loop2() {
  475. var asset = assets[idx];
  476. if (!(asset != null && asset.isDirectory)) {
  477. if (!(asset != null && asset.skipLoading)) {
  478. result.push(asset);
  479. }
  480. } else {
  481. //获取目录下所有资源路径
  482. var dirPath = asset.path.endsWith('/') ? asset.path : asset.path + "/"; //获取带类型信息的资源列表
  483. var allPaths = yield _this9._getBundleAssets(bundle, {
  484. excludeFolders: true,
  485. excludeExtensions: ['.meta']
  486. }); //保留原始类型信息
  487. var dirResources = allPaths.filter(res => res.path.startsWith(dirPath) && !res.path.substring(dirPath.length).includes('/')); //转换时携带类型信息
  488. dirResources.forEach(res => {
  489. result.push({
  490. path: res.path,
  491. type: res.type,
  492. // 保留类型信息
  493. skipLoading: false
  494. });
  495. });
  496. }
  497. };
  498. for (var idx = 0; idx < assets.length; idx++) {
  499. yield* _loop2();
  500. }
  501. result = result.filter(asset => !(asset != null && asset.skipLoading));
  502. return result;
  503. })();
  504. }
  505. /**
  506. * 触发进度回调
  507. */
  508. _updateProgress(onProgress) {
  509. //传递进度状态的副本,避免外部修改
  510. onProgress == null || onProgress(_extends({}, this._loadProgress));
  511. }
  512. /**
  513. * 重置加载进度状态
  514. */
  515. _resetProgress() {
  516. this._loadProgress = {
  517. totalSteps: this._loadProgress.totalSteps,
  518. // 保持总步骤数
  519. completedSteps: 0,
  520. currentBundle: '',
  521. currentAsset: '',
  522. bundleProgress: 0,
  523. totalProgress: 0
  524. };
  525. }
  526. /**
  527. * 明确指定元组类型
  528. * @param asset 未使用这个方法 之前在测试
  529. * { path: 'texture/msg_hint/spriteFrame', type: SpriteFrame },
  530. { path: 'texture/test_01/texture', type: Texture2D },
  531. 这两种的时候有写到
  532. */
  533. _getLoadArguments(asset) {
  534. // 返回元组类型
  535. if (asset.type === SpriteFrame) {
  536. return [asset.path, asset.type];
  537. }
  538. return asset.type ? [asset.path, asset.type] : [asset.path];
  539. }
  540. }) || _class); //全局单例
  541. _export("bundleMgr", bundleMgr = BundleManager.ins());
  542. _cclegacy._RF.pop();
  543. _crd = false;
  544. }
  545. };
  546. });
  547. //# sourceMappingURL=a3ceb9baa9ec92dce895d8c30568a194aeb574e7.js.map