[LayaAir3]插件开发中,我需要选择文件夹,如何可视化选择文件夹

 
如同所示,我需要像【制作图集】插件一样,点击按钮选择文件夹。我要如何处理才能出现选择文件夹的弹窗?有示例吗
 
已邀请:

ZPJ

赞同来自:

Snipaste_2025-07-02_09-58-36.png

 

ZPJ

赞同来自:

在ui编辑器上没有摸索到如何处理。只能通过代码处理了。
export class SplitAtlasDialog extends IEditor.Dialog {

async create() {
let panel = IEditor.GUIUtils.createInspectorPanel();
let data = Editor.getSettings("SplitAtlasSetting").data;
panel.inspect(data, "SplitAtlasSetting");
this.contentPane = panel;

panel.on("click_start_gen", this.startGen, this);
}

protected onShown() {
(this.contentPane as IEditor.InspectorPanel).resetDefault();
this.title = "SplitAtlas";
this.setSize(450, 180);
}
}
class SplitAtlasSetting {
@IEditor.onLoad
static start() {
Editor.typeRegistry.addTypes([
{
name: "SplitAtlasSetting",
catalogBarStyle: "hidden",
properties: [
{
name: "help",
caption: "提示",
inspector: "Info",
type: "string",
default: "输入文件夹中需要有图集文件,输出目录会生成分割后的图片。",
},
{
name: "inputPath",
caption: "输入目录",
inspector: "File",
options: {
absolutePath: true,
properties: ["openDirectory"]
},
type: "string",
},
{
name: "outputPath",
caption: "输出目录",
inspector: "File",
options: {
absolutePath: true,
properties: ["openDirectory"],
},
type: "string",
},
{
name: "",
inspector: "Buttons",
options: { buttons: [{ caption: "生成", event: "click_start_gen" }] }
}
]
}
]);
Editor.extensionManager.createSettings("SplitAtlasSetting", "project");
}
}

LayaAir小牛

赞同来自:

方法为Editor.showOpenDialog

要回复问题请先

商务合作
商务合作