From 4d9fd78c3a9d45b1e11f6550495f9d2786882200 Mon Sep 17 00:00:00 2001 From: NTG_Lenovo Date: Tue, 22 Jul 2025 16:46:07 +0900 Subject: [PATCH] =?UTF-8?q?FadeUi=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=88=9C=EC=84=9C=20=EC=98=A4=EB=A5=98=20=EB=B0=8F=20=EB=8F=99?= =?UTF-8?q?=EC=A0=81=20=ED=95=A0=EB=8B=B9=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/_DDD/_Scripts/GameEvent/GameEvents.cs | 4 ++-- Assets/_DDD/_Scripts/GameUi/FadeUi.cs | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs b/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs index cafd583ee..bf7a57eff 100644 --- a/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs +++ b/Assets/_DDD/_Scripts/GameEvent/GameEvents.cs @@ -35,7 +35,7 @@ public class TimeScaleChangeEvent : IEvent public class FadeInEvent : IEvent { public float Duration; - public TaskCompletionSource CompletionSource; + public TaskCompletionSource CompletionSource = new(); public Task WaitAsync() => CompletionSource.Task; } @@ -43,7 +43,7 @@ public class FadeInEvent : IEvent public class FadeOutEvent : IEvent { public float Duration; - public TaskCompletionSource CompletionSource; + public TaskCompletionSource CompletionSource = new(); public Task WaitAsync() => CompletionSource.Task; } diff --git a/Assets/_DDD/_Scripts/GameUi/FadeUi.cs b/Assets/_DDD/_Scripts/GameUi/FadeUi.cs index 4469828d9..7f332230f 100644 --- a/Assets/_DDD/_Scripts/GameUi/FadeUi.cs +++ b/Assets/_DDD/_Scripts/GameUi/FadeUi.cs @@ -6,19 +6,24 @@ namespace DDD public class FadeUi : MonoBehaviour, IEventHandler, IEventHandler { private CanvasGroup _canvasGroup; + private GameObject _panel; private void Awake() { _canvasGroup = GetComponent(); + _panel = transform.Find(CommonConstants.Panel).gameObject; _canvasGroup.alpha = 0f; - _canvasGroup.gameObject.SetActive(false); - + _panel.SetActive(false); + } + + private void OnEnable() + { EventBus.Register(this); EventBus.Register(this); } - private void OnDestroy() + private void OnDisable() { EventBus.Unregister(this); EventBus.Unregister(this); @@ -29,17 +34,15 @@ public async void Invoke(FadeInEvent evt) await _canvasGroup.DOFade(0f, evt.Duration) .SetUpdate(true) .AsyncWaitForCompletion(); - - _canvasGroup.blocksRaycasts = false; - _canvasGroup.gameObject.SetActive(false); + + _panel.SetActive(false); evt.CompletionSource.SetResult(true); } public async void Invoke(FadeOutEvent evt) { - _canvasGroup.gameObject.SetActive(true); - _canvasGroup.blocksRaycasts = true; + _panel.SetActive(true); await _canvasGroup.DOFade(1f, evt.Duration) .SetUpdate(true)