[LayaAir3]IEditorEnv is not defined,LayaAir3写插件读取文件的时候总是报错
1.这边是调用
@IEditor.menu("App/BuildTable/BuildingTable")
static async genTable() {
console.log("click menu");
await Editor.scene.runScript("CSVToTs.readFileLines");
await Editor.showDialog(GenTableDialog , null);
}
2.这边是具体内容
//读取文件内容,返回 Promise<string[]>
@IEditorEnv.regClass()
private static readFileLines(path: string, encoding: string = "utf-8"): Promise<string[]> {
return new Promise((resolve, reject) => {
Laya.loader.load(path, Laya.Handler.create(null, (content: string) => {
const lines = content.split(/\r?\n/);
resolve(lines);
}), null, Laya.Loader.TEXT, 1, false, encoding);
});
}
@IEditor.menu("App/BuildTable/BuildingTable")
static async genTable() {
console.log("click menu");
await Editor.scene.runScript("CSVToTs.readFileLines");
await Editor.showDialog(GenTableDialog , null);
}
2.这边是具体内容
//读取文件内容,返回 Promise<string[]>
@IEditorEnv.regClass()
private static readFileLines(path: string, encoding: string = "utf-8"): Promise<string[]> {
return new Promise((resolve, reject) => {
Laya.loader.load(path, Laya.Handler.create(null, (content: string) => {
const lines = content.split(/\r?\n/);
resolve(lines);
}), null, Laya.Loader.TEXT, 1, false, encoding);
});
}
没有找到相关结果
已邀请:
要回复问题请先登录
0 个回复