在fgui里制作一个弹窗
-
新建一个按钮,作为返回按钮

-
新建一个标签


做成这个样子
其中包含两个节点,名称分别为title和closeButton
可以阅读fgui的源码window.js得到,closeButton按钮只需要输入名称即可在contentPane设置时自动绑定。

且会自动绑定上关闭事件

-
新建一个组件,做成这个样子

在这里写上标题,就会自动显示。

-
给这个弹窗编写一个脚本
import * as cc from 'cc';
import * as fgui from "fairygui-cc";
const { ccclass, property } = cc._decorator;@ccclass('Setting')
export class Setting extends fgui.Window {public constructor() {super();}protected onInit(): void {this.contentPane = fgui.UIPackage.createObject("GamePkg", "Setting").asCom;this.center();}}
- 弹出时的函数调用:
private _onClicSettingBtn(evt: Event): void {this.SettingWindow = new Setting();this.SettingWindow.show();
}
- 运行
