update
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import { _decorator, resources, BufferAsset, Component } from "cc";
|
||||
import {
|
||||
_decorator,
|
||||
resources,
|
||||
BufferAsset,
|
||||
Component,
|
||||
assetManager,
|
||||
AssetManager,
|
||||
} from "cc";
|
||||
import * as cfg from "../../schema/schema";
|
||||
import ByteBuf from "db://assets/Scripts/luban/ByteBuf";
|
||||
|
||||
@@ -22,9 +29,27 @@ export default class ConfigManager extends Component {
|
||||
let promises: Promise<unknown>[] = [];
|
||||
for (let curFileName of ConfigManager.jsonFileNames) {
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
resources.load("test/" + curFileName, BufferAsset, (err, data) => {
|
||||
resolve(data);
|
||||
});
|
||||
let bundle = assetManager.getBundle("DataTable");
|
||||
if (bundle) {
|
||||
bundle.load(curFileName, BufferAsset, (err, data) => {
|
||||
resolve(data);
|
||||
});
|
||||
} else {
|
||||
assetManager.loadBundle(
|
||||
"DataTable",
|
||||
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
reject && reject(err);
|
||||
return;
|
||||
} else {
|
||||
_bundle.load(curFileName, BufferAsset, (err, data) => {
|
||||
resolve(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
promise.then((data: BufferAsset) => {
|
||||
if (data) {
|
||||
@@ -41,7 +66,7 @@ export default class ConfigManager extends Component {
|
||||
Promise.all(promises).then((values) => {
|
||||
console.log("静态配置加载完成");
|
||||
ConfigManager.tables = new cfg.Tables(this.getFileData);
|
||||
for (let item of ConfigManager.tables.Tbitem.getDataList()) {
|
||||
for (let item of ConfigManager.tables.TbGirls.getDataList()) {
|
||||
console.log(item);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user