From e8b937e0a631f17c75fa0891b018b6941345616b Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Thu, 9 Jan 2025 09:43:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E5=87=BA=E6=A8=A1=E5=9D=97=E9=9A=90?= =?UTF-8?q?=E8=97=8FUI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Art/UIPrefab/UIOperationList.prefab | 10 +++--- Assets/Scripts/UI/UIBtns.cs | 1 + Assets/Scripts/UI/UICameraSwitch.cs | 1 + Assets/Scripts/UI/UIDeviceTip.cs | 1 + Assets/Scripts/UI/UIHint.cs | 1 + Assets/Scripts/UI/UIInstruction.cs | 1 + Assets/Scripts/UI/UILoading.cs | 1 + Assets/Scripts/UI/UIOperationList.cs | 3 +- Assets/Scripts/UI/UIPointQuestion.cs | 1 + Assets/Scripts/UI/UIResultTip.cs | 1 + Assets/Scripts/UI/UIRightTop.cs | 2 -- Assets/Scripts/UI/UIScore.cs | 1 + Assets/Scripts/UI/UITextQuestion.cs | 1 + Assets/Scripts/UI/UITextTip.cs | 1 + Assets/Scripts/UI/UITimeTip.cs | 1 + Assets/Scripts/UI/UITipWindow.cs | 1 + Assets/Scripts/UI/UITools.cs | 2 +- Assets/Scripts/UI/UIVideo.cs | 40 ++++++++++++---------- 18 files changed, 43 insertions(+), 27 deletions(-) diff --git a/Assets/Art/UIPrefab/UIOperationList.prefab b/Assets/Art/UIPrefab/UIOperationList.prefab index 004eae42..e387fe22 100644 --- a/Assets/Art/UIPrefab/UIOperationList.prefab +++ b/Assets/Art/UIPrefab/UIOperationList.prefab @@ -763,7 +763,7 @@ MonoBehaviour: m_ScrollSensitivity: 1 m_Viewport: {fileID: 8731652694218410629} m_HorizontalScrollbar: {fileID: 0} - m_VerticalScrollbar: {fileID: 1945366071212582513} + m_VerticalScrollbar: {fileID: 0} m_HorizontalScrollbarVisibility: 2 m_VerticalScrollbarVisibility: 2 m_HorizontalScrollbarSpacing: -3 @@ -1068,7 +1068,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &6772576175566796072 RectTransform: m_ObjectHideFlags: 0 @@ -1248,9 +1248,9 @@ RectTransform: m_Father: {fileID: 2192231524565599668} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 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_SizeDelta: {x: 0, y: 0} + m_SizeDelta: {x: -12, y: 0} m_Pivot: {x: 0, y: 1} --- !u!222 &1726614218311108045 CanvasRenderer: @@ -1336,7 +1336,7 @@ RectTransform: m_Father: {fileID: 1644315794790874757} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 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_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} diff --git a/Assets/Scripts/UI/UIBtns.cs b/Assets/Scripts/UI/UIBtns.cs index d55ca9a4..4b9414ca 100644 --- a/Assets/Scripts/UI/UIBtns.cs +++ b/Assets/Scripts/UI/UIBtns.cs @@ -19,6 +19,7 @@ namespace QFramework.Example mData = uiData as UIBtnsData ?? new UIBtnsData(); // please add init code here TypeEventSystem.Global.Register(OnStepChanged); + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } private void OnStepChanged(StepStatusOnChange change) diff --git a/Assets/Scripts/UI/UICameraSwitch.cs b/Assets/Scripts/UI/UICameraSwitch.cs index 045681dd..4020e826 100644 --- a/Assets/Scripts/UI/UICameraSwitch.cs +++ b/Assets/Scripts/UI/UICameraSwitch.cs @@ -22,6 +22,7 @@ namespace QFramework.Example { protected override void OnInit(IUIData uiData = null) { + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); mData = uiData as UICameraSwitchData ?? new UICameraSwitchData(); // please add init code here Near.onValueChanged.AddListener(isOn => diff --git a/Assets/Scripts/UI/UIDeviceTip.cs b/Assets/Scripts/UI/UIDeviceTip.cs index 1724395a..1b94bf72 100644 --- a/Assets/Scripts/UI/UIDeviceTip.cs +++ b/Assets/Scripts/UI/UIDeviceTip.cs @@ -13,6 +13,7 @@ namespace QFramework.Example { mData = uiData as UIDeviceTipData ?? new UIDeviceTipData(); // please add init code here + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } protected override void OnOpen(IUIData uiData = null) diff --git a/Assets/Scripts/UI/UIHint.cs b/Assets/Scripts/UI/UIHint.cs index 73deb610..6a30db99 100644 --- a/Assets/Scripts/UI/UIHint.cs +++ b/Assets/Scripts/UI/UIHint.cs @@ -23,6 +23,7 @@ namespace QFramework.Example mData = uiData as UIHintData ?? new UIHintData(); SetItem(0); TypeEventSystem.Global.Register(OnStepChanged); + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } private void OnStepChanged(StepStatusOnChange change) diff --git a/Assets/Scripts/UI/UIInstruction.cs b/Assets/Scripts/UI/UIInstruction.cs index 8ba88f6c..aa7d6981 100644 --- a/Assets/Scripts/UI/UIInstruction.cs +++ b/Assets/Scripts/UI/UIInstruction.cs @@ -12,6 +12,7 @@ namespace QFramework.Example { protected override void OnInit(IUIData uiData = null) { + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); mData = uiData as UIInstructionData ?? new UIInstructionData(); // please add init code here Training.onValueChanged.AddListener(isOn => diff --git a/Assets/Scripts/UI/UILoading.cs b/Assets/Scripts/UI/UILoading.cs index e65ab0cd..6d7ed682 100644 --- a/Assets/Scripts/UI/UILoading.cs +++ b/Assets/Scripts/UI/UILoading.cs @@ -14,6 +14,7 @@ namespace QFramework.Example protected override void OnInit(IUIData uiData = null) { mData = uiData as UILoadingData ?? new UILoadingData(); + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); TypeEventSystem.Global.Register(arg => Show()).UnRegisterWhenGameObjectDestroyed(gameObject); TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } diff --git a/Assets/Scripts/UI/UIOperationList.cs b/Assets/Scripts/UI/UIOperationList.cs index 7e4a9d18..58c14ec6 100644 --- a/Assets/Scripts/UI/UIOperationList.cs +++ b/Assets/Scripts/UI/UIOperationList.cs @@ -21,6 +21,7 @@ namespace QFramework.Example { mData = uiData as UIOperationListData ?? new UIOperationListData(); TypeEventSystem.Global.Register(OnStepChanged); + TypeEventSystem.Global.Register((arg)=>Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } private void OnStepChanged(StepStatusOnChange change) @@ -67,7 +68,7 @@ namespace QFramework.Example break; case StepStatus.Finished: // TODOʵַʽ Ż - if (Global.Instance.curModule.type=="Exam") + if (Global.Instance.curModule.type == "Exam") { stepLabel.color = highColor; } diff --git a/Assets/Scripts/UI/UIPointQuestion.cs b/Assets/Scripts/UI/UIPointQuestion.cs index cb8ba3e3..8f60f828 100644 --- a/Assets/Scripts/UI/UIPointQuestion.cs +++ b/Assets/Scripts/UI/UIPointQuestion.cs @@ -18,6 +18,7 @@ namespace QFramework.Example mData = uiData as UIPointQuestionData ?? new UIPointQuestionData(); // please add init code here TypeEventSystem.Global.Register(OnStepChanged); + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } private void OnStepChanged(StepStatusOnChange change) diff --git a/Assets/Scripts/UI/UIResultTip.cs b/Assets/Scripts/UI/UIResultTip.cs index 8e613038..288574e1 100644 --- a/Assets/Scripts/UI/UIResultTip.cs +++ b/Assets/Scripts/UI/UIResultTip.cs @@ -21,6 +21,7 @@ namespace QFramework.Example Right.gameObject.SetActive(false); Wrong.gameObject.SetActive(false); TypeEventSystem.Global.Register(OnStepChanged); + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } private void OnStepChanged(StepStatusOnChange change) diff --git a/Assets/Scripts/UI/UIRightTop.cs b/Assets/Scripts/UI/UIRightTop.cs index 374c4de5..1350a967 100644 --- a/Assets/Scripts/UI/UIRightTop.cs +++ b/Assets/Scripts/UI/UIRightTop.cs @@ -13,8 +13,6 @@ namespace QFramework.Example protected override void OnInit(IUIData uiData = null) { mData = uiData as UIRightTopData ?? new UIRightTopData(); - - setBtn.onClick.AddListener(() => { UIKit.OpenPanelAsync(canvasLevel: UILevel.PopUI).ToAction().StartGlobal(); diff --git a/Assets/Scripts/UI/UIScore.cs b/Assets/Scripts/UI/UIScore.cs index c3995dcd..4856c51e 100644 --- a/Assets/Scripts/UI/UIScore.cs +++ b/Assets/Scripts/UI/UIScore.cs @@ -12,6 +12,7 @@ namespace QFramework.Example protected override void OnInit(IUIData uiData = null) { mData = uiData as UIScoreData ?? new UIScoreData(); + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); DownLoad.onClick.AddListener(() => { if (string.IsNullOrEmpty(InputName.text) || string.IsNullOrEmpty(InputId.text)) diff --git a/Assets/Scripts/UI/UITextQuestion.cs b/Assets/Scripts/UI/UITextQuestion.cs index b1e6d874..3069230a 100644 --- a/Assets/Scripts/UI/UITextQuestion.cs +++ b/Assets/Scripts/UI/UITextQuestion.cs @@ -35,6 +35,7 @@ namespace QFramework.Example mData = uiData as UITextQuestionData ?? new UITextQuestionData(); // please add init code here TypeEventSystem.Global.Register(OnStepChanged); + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } private void OnStepChanged(StepStatusOnChange change) diff --git a/Assets/Scripts/UI/UITextTip.cs b/Assets/Scripts/UI/UITextTip.cs index b7738738..d09da503 100644 --- a/Assets/Scripts/UI/UITextTip.cs +++ b/Assets/Scripts/UI/UITextTip.cs @@ -21,6 +21,7 @@ namespace QFramework.Example mData = uiData as UITextTipData ?? new UITextTipData(); + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } protected override void OnOpen(IUIData uiData = null) diff --git a/Assets/Scripts/UI/UITimeTip.cs b/Assets/Scripts/UI/UITimeTip.cs index 1e78169c..5cb20689 100644 --- a/Assets/Scripts/UI/UITimeTip.cs +++ b/Assets/Scripts/UI/UITimeTip.cs @@ -42,6 +42,7 @@ namespace QFramework.Example { mData = uiData as UITimeTipData ?? new UITimeTipData(); // please add init code here + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } private void Update() diff --git a/Assets/Scripts/UI/UITipWindow.cs b/Assets/Scripts/UI/UITipWindow.cs index 6dde5a40..0ed8613c 100644 --- a/Assets/Scripts/UI/UITipWindow.cs +++ b/Assets/Scripts/UI/UITipWindow.cs @@ -28,6 +28,7 @@ namespace QFramework.Example // please add init code here TypeEventSystem.Global.Register(OnStepChanged); + TypeEventSystem.Global.Register((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject); } private void OnStepChanged(StepStatusOnChange change) diff --git a/Assets/Scripts/UI/UITools.cs b/Assets/Scripts/UI/UITools.cs index 666c3b14..49bc1571 100644 --- a/Assets/Scripts/UI/UITools.cs +++ b/Assets/Scripts/UI/UITools.cs @@ -31,6 +31,7 @@ namespace QFramework.Example mData = uiData as UIToolsData ?? new UIToolsData(); // please add init code here TypeEventSystem.Global.Register(OnStepChanged); + TypeEventSystem.Global.Register(OnModuleQuit).UnRegisterWhenGameObjectDestroyed(gameObject); } private void OnStepChanged(StepStatusOnChange change) @@ -40,7 +41,6 @@ namespace QFramework.Example protected override void OnOpen(IUIData uiData = null) { - TypeEventSystem.Global.Register(OnModuleQuit).UnRegisterWhenDisabled(gameObject); mResLoader = ResLoader.Allocate(); mData = uiData as UIToolsData ?? new UIToolsData(); if (string.IsNullOrEmpty(mData.answer) == false) diff --git a/Assets/Scripts/UI/UIVideo.cs b/Assets/Scripts/UI/UIVideo.cs index 4cc5a1cf..0c617ca8 100644 --- a/Assets/Scripts/UI/UIVideo.cs +++ b/Assets/Scripts/UI/UIVideo.cs @@ -24,30 +24,14 @@ namespace QFramework.Example protected override void OnInit(IUIData uiData = null) { mData = uiData as UIVideoData ?? new UIVideoData(); + TypeEventSystem.Global.Register((arg) => Close()).UnRegisterWhenGameObjectDestroyed(gameObject); // please add init code here Progress.onValueChanged.AddListener(OnSliderValueChanged); Progress.OnBeginDragEvent(OnProgressBeginDrag); Progress.OnEndDragEvent(OnProgressEndDrag); player.loopPointReached += VideoPlayer_loopPointReached; player.prepareCompleted += OnPrepareCompleted; - CloseBtn.onClick.AddListener(() => - { - 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(); - }); + CloseBtn.onClick.AddListener(Close); VideoPlayBtn.onClick.AddListener(() => { 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) { Progress.maxValue = (float)player.length;