增加模块退出事件监听

This commit is contained in:
shenjianxing 2025-03-11 10:33:07 +08:00
parent 2e0e17543a
commit 788e8d72b5
4 changed files with 23 additions and 1 deletions

View File

@ -57,6 +57,7 @@ namespace QFramework.Example
Dictionary<string, BodyListItem> bodyListIndex = new Dictionary<string, BodyListItem>(); Dictionary<string, BodyListItem> bodyListIndex = new Dictionary<string, BodyListItem>();
protected override void OnInit(IUIData uiData = null) protected override void OnInit(IUIData uiData = null)
{ {
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuithandler).UnRegisterWhenGameObjectDestroyed(this);
DragBtn.onValueChanged.AddListener(isOn => DragBtn.onValueChanged.AddListener(isOn =>
{ {
DragBtn.transform.Find("SubBtns").gameObject.SetActive(isOn); DragBtn.transform.Find("SubBtns").gameObject.SetActive(isOn);
@ -146,6 +147,10 @@ namespace QFramework.Example
}); });
} }
private void OnModuleQuithandler(OnModuleQuit quit)
{
Hide();
}
private void OnUIDrawClose() private void OnUIDrawClose()
{ {

View File

@ -18,6 +18,7 @@ namespace QFramework.Example
float bgH; float bgH;
protected override void OnInit(IUIData uiData = null) protected override void OnInit(IUIData uiData = null)
{ {
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuithandler).UnRegisterWhenGameObjectDestroyed(this);
bgH = Content.sizeDelta.y; bgH = Content.sizeDelta.y;
Group.onValueChanged.AddListener(isOn => Group.onValueChanged.AddListener(isOn =>
{ {
@ -122,6 +123,11 @@ namespace QFramework.Example
} }
private void OnModuleQuithandler(OnModuleQuit quit)
{
Hide();
}
public void RefreshTipPath() public void RefreshTipPath()
{ {
ListContent.RemoveAllChildren(); ListContent.RemoveAllChildren();

View File

@ -4,6 +4,7 @@ using XMLTool;
using System.Collections.Generic; using System.Collections.Generic;
using TMPro; using TMPro;
using DG.Tweening; using DG.Tweening;
using System;
namespace QFramework.Example namespace QFramework.Example
{ {
@ -204,6 +205,7 @@ namespace QFramework.Example
DOTweenAnimation contentAnim; DOTweenAnimation contentAnim;
protected override void OnInit(IUIData uiData = null) protected override void OnInit(IUIData uiData = null)
{ {
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuithandler).UnRegisterWhenGameObjectDestroyed(this);
contentAnim = RootContent.GetComponent<DOTweenAnimation>(); contentAnim = RootContent.GetComponent<DOTweenAnimation>();
// please add init code here // please add init code here
Close.onClick.AddListener(() => Close.onClick.AddListener(() =>
@ -233,7 +235,10 @@ namespace QFramework.Example
}); });
} }
private void OnModuleQuithandler(OnModuleQuit quit)
{
Hide();
}
protected override void OnOpen(IUIData uiData = null) protected override void OnOpen(IUIData uiData = null)
{ {

View File

@ -15,6 +15,7 @@ namespace QFramework.Example
private bool isObjectHit; // 标记是否有物体被击中 private bool isObjectHit; // 标记是否有物体被击中
protected override void OnInit(IUIData uiData = null) protected override void OnInit(IUIData uiData = null)
{ {
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuithandler).UnRegisterWhenGameObjectDestroyed(this);
mData = uiData as UIBody3DMouseData ?? new UIBody3DMouseData(); mData = uiData as UIBody3DMouseData ?? new UIBody3DMouseData();
dragItem = Content.GetComponent<UIDragItem>(); dragItem = Content.GetComponent<UIDragItem>();
@ -31,6 +32,11 @@ namespace QFramework.Example
}); });
} }
private void OnModuleQuithandler(OnModuleQuit quit)
{
Hide();
}
private void OnEndDrag() private void OnEndDrag()
{ {
Show3DCamera.instance.lockMove = false; Show3DCamera.instance.lockMove = false;