退出模块隐藏UI

This commit is contained in:
shenjianxing 2025-01-09 09:43:15 +08:00
parent abc7ffedc4
commit e8b937e0a6
18 changed files with 43 additions and 27 deletions

View File

@ -763,7 +763,7 @@ MonoBehaviour:
m_ScrollSensitivity: 1 m_ScrollSensitivity: 1
m_Viewport: {fileID: 8731652694218410629} m_Viewport: {fileID: 8731652694218410629}
m_HorizontalScrollbar: {fileID: 0} m_HorizontalScrollbar: {fileID: 0}
m_VerticalScrollbar: {fileID: 1945366071212582513} m_VerticalScrollbar: {fileID: 0}
m_HorizontalScrollbarVisibility: 2 m_HorizontalScrollbarVisibility: 2
m_VerticalScrollbarVisibility: 2 m_VerticalScrollbarVisibility: 2
m_HorizontalScrollbarSpacing: -3 m_HorizontalScrollbarSpacing: -3
@ -1068,7 +1068,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!224 &6772576175566796072 --- !u!224 &6772576175566796072
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1248,9 +1248,9 @@ RectTransform:
m_Father: {fileID: 2192231524565599668} m_Father: {fileID: 2192231524565599668}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: -12, y: 0}
m_Pivot: {x: 0, y: 1} m_Pivot: {x: 0, y: 1}
--- !u!222 &1726614218311108045 --- !u!222 &1726614218311108045
CanvasRenderer: CanvasRenderer:
@ -1336,7 +1336,7 @@ RectTransform:
m_Father: {fileID: 1644315794790874757} m_Father: {fileID: 1644315794790874757}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}

View File

@ -19,6 +19,7 @@ namespace QFramework.Example
mData = uiData as UIBtnsData ?? new UIBtnsData(); mData = uiData as UIBtnsData ?? new UIBtnsData();
// please add init code here // please add init code here
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged); TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
private void OnStepChanged(StepStatusOnChange change) private void OnStepChanged(StepStatusOnChange change)

View File

@ -22,6 +22,7 @@ namespace QFramework.Example
{ {
protected override void OnInit(IUIData uiData = null) protected override void OnInit(IUIData uiData = null)
{ {
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
mData = uiData as UICameraSwitchData ?? new UICameraSwitchData(); mData = uiData as UICameraSwitchData ?? new UICameraSwitchData();
// please add init code here // please add init code here
Near.onValueChanged.AddListener(isOn => Near.onValueChanged.AddListener(isOn =>

View File

@ -13,6 +13,7 @@ namespace QFramework.Example
{ {
mData = uiData as UIDeviceTipData ?? new UIDeviceTipData(); mData = uiData as UIDeviceTipData ?? new UIDeviceTipData();
// please add init code here // please add init code here
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
protected override void OnOpen(IUIData uiData = null) protected override void OnOpen(IUIData uiData = null)

View File

@ -23,6 +23,7 @@ namespace QFramework.Example
mData = uiData as UIHintData ?? new UIHintData(); mData = uiData as UIHintData ?? new UIHintData();
SetItem(0); SetItem(0);
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged); TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
private void OnStepChanged(StepStatusOnChange change) private void OnStepChanged(StepStatusOnChange change)

View File

@ -12,6 +12,7 @@ namespace QFramework.Example
{ {
protected override void OnInit(IUIData uiData = null) protected override void OnInit(IUIData uiData = null)
{ {
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
mData = uiData as UIInstructionData ?? new UIInstructionData(); mData = uiData as UIInstructionData ?? new UIInstructionData();
// please add init code here // please add init code here
Training.onValueChanged.AddListener(isOn => Training.onValueChanged.AddListener(isOn =>

View File

@ -14,6 +14,7 @@ namespace QFramework.Example
protected override void OnInit(IUIData uiData = null) protected override void OnInit(IUIData uiData = null)
{ {
mData = uiData as UILoadingData ?? new UILoadingData(); mData = uiData as UILoadingData ?? new UILoadingData();
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
TypeEventSystem.Global.Register<OnLoadingShow>(arg => Show()).UnRegisterWhenGameObjectDestroyed(gameObject); TypeEventSystem.Global.Register<OnLoadingShow>(arg => Show()).UnRegisterWhenGameObjectDestroyed(gameObject);
TypeEventSystem.Global.Register<OnLoadingHide>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); TypeEventSystem.Global.Register<OnLoadingHide>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }

View File

@ -21,6 +21,7 @@ namespace QFramework.Example
{ {
mData = uiData as UIOperationListData ?? new UIOperationListData(); mData = uiData as UIOperationListData ?? new UIOperationListData();
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged); TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
TypeEventSystem.Global.Register<OnModuleQuit>((arg)=>Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
private void OnStepChanged(StepStatusOnChange change) private void OnStepChanged(StepStatusOnChange change)
@ -67,7 +68,7 @@ namespace QFramework.Example
break; break;
case StepStatus.Finished: case StepStatus.Finished:
// TODO实现方式过于耦合 后期优化 // TODO实现方式过于耦合 后期优化
if (Global.Instance.curModule.type=="Exam") if (Global.Instance.curModule.type == "Exam")
{ {
stepLabel.color = highColor; stepLabel.color = highColor;
} }

View File

@ -18,6 +18,7 @@ namespace QFramework.Example
mData = uiData as UIPointQuestionData ?? new UIPointQuestionData(); mData = uiData as UIPointQuestionData ?? new UIPointQuestionData();
// please add init code here // please add init code here
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged); TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
private void OnStepChanged(StepStatusOnChange change) private void OnStepChanged(StepStatusOnChange change)

View File

@ -21,6 +21,7 @@ namespace QFramework.Example
Right.gameObject.SetActive(false); Right.gameObject.SetActive(false);
Wrong.gameObject.SetActive(false); Wrong.gameObject.SetActive(false);
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged); TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
private void OnStepChanged(StepStatusOnChange change) private void OnStepChanged(StepStatusOnChange change)

View File

@ -13,8 +13,6 @@ namespace QFramework.Example
protected override void OnInit(IUIData uiData = null) protected override void OnInit(IUIData uiData = null)
{ {
mData = uiData as UIRightTopData ?? new UIRightTopData(); mData = uiData as UIRightTopData ?? new UIRightTopData();
setBtn.onClick.AddListener(() => setBtn.onClick.AddListener(() =>
{ {
UIKit.OpenPanelAsync<UISetting>(canvasLevel: UILevel.PopUI).ToAction().StartGlobal(); UIKit.OpenPanelAsync<UISetting>(canvasLevel: UILevel.PopUI).ToAction().StartGlobal();

View File

@ -12,6 +12,7 @@ namespace QFramework.Example
protected override void OnInit(IUIData uiData = null) protected override void OnInit(IUIData uiData = null)
{ {
mData = uiData as UIScoreData ?? new UIScoreData(); mData = uiData as UIScoreData ?? new UIScoreData();
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
DownLoad.onClick.AddListener(() => DownLoad.onClick.AddListener(() =>
{ {
if (string.IsNullOrEmpty(InputName.text) || string.IsNullOrEmpty(InputId.text)) if (string.IsNullOrEmpty(InputName.text) || string.IsNullOrEmpty(InputId.text))

View File

@ -35,6 +35,7 @@ namespace QFramework.Example
mData = uiData as UITextQuestionData ?? new UITextQuestionData(); mData = uiData as UITextQuestionData ?? new UITextQuestionData();
// please add init code here // please add init code here
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged); TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
private void OnStepChanged(StepStatusOnChange change) private void OnStepChanged(StepStatusOnChange change)

View File

@ -21,6 +21,7 @@ namespace QFramework.Example
mData = uiData as UITextTipData ?? new UITextTipData(); mData = uiData as UITextTipData ?? new UITextTipData();
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
protected override void OnOpen(IUIData uiData = null) protected override void OnOpen(IUIData uiData = null)

View File

@ -42,6 +42,7 @@ namespace QFramework.Example
{ {
mData = uiData as UITimeTipData ?? new UITimeTipData(); mData = uiData as UITimeTipData ?? new UITimeTipData();
// please add init code here // please add init code here
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
private void Update() private void Update()

View File

@ -28,6 +28,7 @@ namespace QFramework.Example
// please add init code here // please add init code here
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged); TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
private void OnStepChanged(StepStatusOnChange change) private void OnStepChanged(StepStatusOnChange change)

View File

@ -31,6 +31,7 @@ namespace QFramework.Example
mData = uiData as UIToolsData ?? new UIToolsData(); mData = uiData as UIToolsData ?? new UIToolsData();
// please add init code here // please add init code here
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged); TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuit).UnRegisterWhenGameObjectDestroyed(gameObject);
} }
private void OnStepChanged(StepStatusOnChange change) private void OnStepChanged(StepStatusOnChange change)
@ -40,7 +41,6 @@ namespace QFramework.Example
protected override void OnOpen(IUIData uiData = null) protected override void OnOpen(IUIData uiData = null)
{ {
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuit).UnRegisterWhenDisabled(gameObject);
mResLoader = ResLoader.Allocate(); mResLoader = ResLoader.Allocate();
mData = uiData as UIToolsData ?? new UIToolsData(); mData = uiData as UIToolsData ?? new UIToolsData();
if (string.IsNullOrEmpty(mData.answer) == false) if (string.IsNullOrEmpty(mData.answer) == false)

View File

@ -24,30 +24,14 @@ namespace QFramework.Example
protected override void OnInit(IUIData uiData = null) protected override void OnInit(IUIData uiData = null)
{ {
mData = uiData as UIVideoData ?? new UIVideoData(); mData = uiData as UIVideoData ?? new UIVideoData();
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Close()).UnRegisterWhenGameObjectDestroyed(gameObject);
// please add init code here // please add init code here
Progress.onValueChanged.AddListener(OnSliderValueChanged); Progress.onValueChanged.AddListener(OnSliderValueChanged);
Progress.OnBeginDragEvent(OnProgressBeginDrag); Progress.OnBeginDragEvent(OnProgressBeginDrag);
Progress.OnEndDragEvent(OnProgressEndDrag); Progress.OnEndDragEvent(OnProgressEndDrag);
player.loopPointReached += VideoPlayer_loopPointReached; player.loopPointReached += VideoPlayer_loopPointReached;
player.prepareCompleted += OnPrepareCompleted; player.prepareCompleted += OnPrepareCompleted;
CloseBtn.onClick.AddListener(() => CloseBtn.onClick.AddListener(Close);
{
if (player.isPlaying)
{
player.Stop();
}
if (string.IsNullOrEmpty(mData.finishedEvent) == false)
{
StringEventSystem.Global.Send(mData.finishedEvent);
}
if (string.IsNullOrEmpty(mData.closeEvent) == false)
{
StringEventSystem.Global.Send(mData.closeEvent);
}
player.targetTexture.Release();
Hide();
});
VideoPlayBtn.onClick.AddListener(() => VideoPlayBtn.onClick.AddListener(() =>
{ {
player.Pause(); player.Pause();
@ -80,6 +64,26 @@ namespace QFramework.Example
} }
} }
public void Close()
{
if (player.isPlaying)
{
player.Stop();
}
if (string.IsNullOrEmpty(mData.finishedEvent) == false)
{
StringEventSystem.Global.Send(mData.finishedEvent);
}
if (string.IsNullOrEmpty(mData.closeEvent) == false)
{
StringEventSystem.Global.Send(mData.closeEvent);
}
player.targetTexture.Release();
Hide();
}
private void OnPrepareCompleted(VideoPlayer source) private void OnPrepareCompleted(VideoPlayer source)
{ {
Progress.maxValue = (float)player.length; Progress.maxValue = (float)player.length;