// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html const { ccclass, property } = cc._decorator; @ccclass export default class NewClass extends cc.Component { @property( { type: cc.Node, displayName: "回调节点", } ) callNode: cc.Node = null; @property( { displayName: "是否是启用触发", } ) isEnable: Boolean = false; protected onEnable(): void { if (this.isEnable) { this.callEvent(); } } protected onDisable(): void { if (!this.isEnable) { this.callEvent(); } } callEvent() { if (this.callNode["callback"]) { this.callNode["callback"](); } } }