const { ccclass, property } = _decorator; import { _decorator, Node } from 'cc'; import li_Component from './li_Component'; import Utils from './Utils'; import { ViewManager } from '../Manager/ViewManager'; //界面基类 @ccclass export default class li_BaseView extends li_Component { private isScriptComponent = true;//标记判断使用(勿删) //命名为根节点,实际上是编辑器里可以看到的最上层节点,实际使用时需要getParent来获取根节点 @property({ type: Node, visible: true, displayName: '界面根节点' }) protected m_rootNode: Node = null; protected objNodes: any = null; //----以下接口由子类实现----------------------------- onLoadCT() { } onLoad() { if (this.m_rootNode == null) { this.m_rootNode = this.node; } this.onLoadCT(); } parseNode() { // this.objNodes = {}; // Utils.parseNode(this.node, this.objNodes); // let self = this; // setTimeout(() => { // self.bindBtnClose(); // }, 10); } private bindBtnClose() { } protected getRootNode() { // if (this.node) { // let node = this.node; // let parent = node.getParent(); // let groundParent = parent && parent.getParent(); // while (groundParent) { // node = parent; // parent = groundParent; // groundParent = parent && parent.getParent(); // } // return node; // } } public close() { ViewManager.I.closeView(this.m_rootNode ? this.m_rootNode : this.node); } protected onClose() { // hg_utils.sendInnerMsg(InnerMsgCode.ViewClose) this.close(); } //实际移除界面 protected removeView(): void { if (this.m_rootNode) { this.m_rootNode.destroy(); this.m_rootNode.removeFromParent(); this.m_rootNode = null } } // protected doClose(): void { // this.removeView(); // } }