From cc0d243a3740c2f4948a68f4a9281aaa0a386d39 Mon Sep 17 00:00:00 2001 From: dgflash Date: Wed, 15 Feb 2023 09:17:54 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E9=85=8D=E7=BD=AEconfig.js=E5=88=B0=E9=A1=B9=E7=9B=AE=E6=A0=B9?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=B8=8B=202=E3=80=81=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E9=BB=98=E8=AE=A4=E8=BF=9C=E7=A8=8B=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=8A=A0=E8=BD=BD=E7=9A=84=E9=85=8D=E7=BD=AE=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/core/Root.ts | 4 ++-- assets/core/common/loader/ResLoader.ts | 11 +++++++---- assets/module/config/GameConfig.ts | 19 ++++++++++++++++++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/assets/core/Root.ts b/assets/core/Root.ts index eb332ef..f358b20 100644 --- a/assets/core/Root.ts +++ b/assets/core/Root.ts @@ -2,7 +2,7 @@ * @Author: dgflash * @Date: 2021-07-03 16:13:17 * @LastEditors: dgflash - * @LastEditTime: 2023-01-19 11:48:04 + * @LastEditTime: 2023-02-14 18:07:56 */ import { Component, Game, JsonAsset, Node, _decorator, director, game, log, sys, view } from "cc"; import { LanguageManager } from "../libs/gui/language/Language"; @@ -42,7 +42,7 @@ export class Root extends Component { console.log(`Oops Framework v${version}`); this.enabled = false; - let config_name = "config/config"; + let config_name = "config"; oops.res.load(config_name, JsonAsset, () => { var config = oops.res.get(config_name); oops.config.btc = new BuildTimeConstants(); diff --git a/assets/core/common/loader/ResLoader.ts b/assets/core/common/loader/ResLoader.ts index a492b19..0cdf350 100644 --- a/assets/core/common/loader/ResLoader.ts +++ b/assets/core/common/loader/ResLoader.ts @@ -1,4 +1,4 @@ -import { Asset, AssetManager, assetManager, Constructor, error, js, Prefab, resources, __private } from "cc"; +import { Asset, AssetManager, Constructor, Prefab, __private, assetManager, error, js, resources } from "cc"; type ProgressCallback = __private._cocos_asset_asset_manager_shared__ProgressCallback; type CompleteCallback = __private._cocos_asset_asset_manager_shared__CompleteCallbackWithData; @@ -159,6 +159,7 @@ oops.res.loadDir("game", onProgressCallback, onCompleteCallback); } else { args = this.parseLoadResArgs(bundleName, dir, type, onProgress); + args.bundle = this.defaultBundleName; } args.dir = args.paths as string; this.loadByArgs(args); @@ -224,9 +225,11 @@ oops.res.loadDir("game", onProgressCallback, onCompleteCallback); * @param type 资源类型 * @param bundleName 远程资源包名 */ - get(path: string, type?: __private._cocos_asset_asset_manager_shared__AssetType | null, bundleName: string = "resources"): T | null { - var bundle: AssetManager.Bundle | null = assetManager.getBundle(bundleName); - return bundle!.get(path, type); + get(path: string, type?: __private._cocos_asset_asset_manager_shared__AssetType | null, bundleName?: string): T | null { + if (bundleName == null) bundleName = this.defaultBundleName; + + var bundle: AssetManager.Bundle = assetManager.getBundle(bundleName)!; + return bundle.get(path, type); } /** 打印缓存中所有资源信息 */ diff --git a/assets/module/config/GameConfig.ts b/assets/module/config/GameConfig.ts index 9d7e145..0a9a142 100644 --- a/assets/module/config/GameConfig.ts +++ b/assets/module/config/GameConfig.ts @@ -2,7 +2,7 @@ * @Author: dgflash * @Date: 2021-07-03 16:13:17 * @LastEditors: dgflash - * @LastEditTime: 2022-11-01 15:26:26 + * @LastEditTime: 2023-02-14 14:27:22 */ import { oops } from "../../core/Oops"; @@ -51,6 +51,23 @@ export class GameConfig { return this._data.language.path.texture || "language/texture"; } + /** 是否启用远程资源 */ + get bundleEnable(): string { + return this._data.bundle.enable; + } + /** 远程资源服务器地址 */ + get bundleServer(): string { + return this._data.bundle.server; + } + /** 远程资源名 */ + get bundleName(): string { + return this._data.bundle.name; + } + /** 远程资源版本号 */ + get bundleVersion(): string { + return this._data.bundle.version; + } + private _data: any = null; /** 游戏配置数据 */ public get data(): any {