resources
通常我们会把项目中需要动态加载的资源放在 resources 目录下,配合 resources.load 等接口动态加载。你只要传入相对 resources 的路径即可,并且路径的结尾处 不能 包含文件扩展名。
resources.load("Inf", JsonAsset, (error, asset) => {if (error) {console.log(error);return;}console.log(asset.json);})
assetManager
assetManager.loadBundle("json", (errorBundle, bundle) => {if (errorBundle) {console.log(errorBundle);return;}bundle.load("Inf", JsonAsset, (errorJson, asset) => {if (errorJson) {console.log(errorJson);return;}console.log(asset.json);})});
打包