import AudioUtil from "../core/AudioUtil"; import FGUtil from "../gear_2.3.4/fgui/FGUtil"; import SKUIUtil from "../gear_2.3.4/util/SKUIUtil"; import ItemUtil from "../core/ItemUtil"; const {ccclass, property} = cc._decorator; @ccclass export default class xwSelect extends cc.Component { /** * 信物面板單例實例 */ public static Instance: xwSelect = null; /** * 信物面板 */ xinwu: fgui.GComponent = null; /** * 需要加載的預製體 */ prefabObject: any = {}; onLoad() { if (xwSelect.Instance === null) { xwSelect.Instance = this; this.loadPrefab(); } else { this.destroy(); return; } } loadPrefab() { // 加載所需的預製體 var prefabList = [ // { url: "Prefabs/UIRole", name: "UIRole" }, ] this.prefabObject = {} for (let item of prefabList) { cc.loader.loadRes(item.url, cc.Prefab, (err, prefab) => { if (err) console.warn(err); else { this.prefabObject[item.name] = prefab; } }) } } openXwSelect() { if (!this.xinwu || (this.xinwu && !this.xinwu.node && !SKUIUtil.isValid(this.xinwu.node))) { this.xinwu = FGUtil.create("main_ui", "bagua_my_keepsake"); FGUtil.root().addChild(this.xinwu); FGUtil.fitScreen(this.xinwu) } } }