[HOTFIX] 이펙트 패널 코루틴 실행 전 active 체크 추가

This commit is contained in:
Jay 2025-03-31 10:48:16 +09:00
parent 00aa35d98b
commit 9d03e2a93f
5 changed files with 42 additions and 15 deletions

View File

@ -14,9 +14,9 @@ public class DrawEffectController : EffectController
public override void ShowEffect(OnEffectPanelEnded onEffectPanelEnd) public override void ShowEffect(OnEffectPanelEnded onEffectPanelEnd)
{ {
AudioManager.Instance.PlayDrawSound(); //사운드 추가 AudioManager.Instance.PlayDrawSound(); // 사운드 추가
gameObject.SetActive(true); gameObject.SetActive(true);
cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource = new CancellationTokenSource();
onEffectPanelEnded = onEffectPanelEnd; onEffectPanelEnded = onEffectPanelEnd;
@ -27,6 +27,8 @@ public class DrawEffectController : EffectController
private IEnumerator AnimateCharacterEyes() private IEnumerator AnimateCharacterEyes()
{ {
if (!gameObject.activeInHierarchy) yield return null; // 게임 오브젝트가 비활성화 상태면 실행 안 함
while (!cancellationTokenSource.IsCancellationRequested) while (!cancellationTokenSource.IsCancellationRequested)
{ {
yield return PlayBlinkAnimation(dragonOpenEyes, dragonCloseEyes); yield return PlayBlinkAnimation(dragonOpenEyes, dragonCloseEyes);
@ -62,6 +64,8 @@ public class DrawEffectController : EffectController
// 눈 깜빡이는 애니메이션을 메서드로 분리 // 눈 깜빡이는 애니메이션을 메서드로 분리
private IEnumerator PlayBlinkAnimation(GameObject openEye, GameObject closeEye) private IEnumerator PlayBlinkAnimation(GameObject openEye, GameObject closeEye)
{ {
if (!gameObject.activeInHierarchy) yield return null; // 게임 오브젝트가 비활성화 상태면 실행 안 함
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
openEye.SetActive(false); openEye.SetActive(false);
@ -78,6 +82,8 @@ public class DrawEffectController : EffectController
private void PopupBanner() private void PopupBanner()
{ {
if (!gameObject.activeInHierarchy) return; // 게임 오브젝트가 비활성화 상태면 실행 안 함
tigerCloseEyes.SetActive(false); tigerCloseEyes.SetActive(false);
tigerOpenEyes.SetActive(false); tigerOpenEyes.SetActive(false);
dragonCloseEyes.SetActive(true); dragonCloseEyes.SetActive(true);
@ -108,8 +114,8 @@ public class DrawEffectController : EffectController
.SetDelay(0.2f) // 살짝 더 길게 흔들도록 설정 .SetDelay(0.2f) // 살짝 더 길게 흔들도록 설정
.OnComplete(() => .OnComplete(() =>
{ {
// 애니메이션이 끝난 후 눈 깜빡이는 효과 실행 if (gameObject.activeInHierarchy) // 실행 전에 다시 확인
StartCoroutine(AnimateCharacterEyes()); StartCoroutine(AnimateCharacterEyes()); // 애니메이션이 끝난 후 눈 깜빡이는 효과 실행
}); });
} }
} }

View File

@ -14,16 +14,16 @@ public class LoseEffectController : EffectController
public override void ShowEffect(OnEffectPanelEnded onEffectPanelEnd) public override void ShowEffect(OnEffectPanelEnded onEffectPanelEnd)
{ {
AudioManager.Instance.PlayLoseSound(); //사운드 추가 AudioManager.Instance.PlayLoseSound(); // 사운드 추가
gameObject.SetActive(true); gameObject.SetActive(true);
cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource = new CancellationTokenSource();
onEffectPanelEnded = onEffectPanelEnd; onEffectPanelEnded = onEffectPanelEnd;
ShowPanel(); ShowPanel();
StartCoroutine(AnimateLoadingText()); StartCoroutine(AnimateLoadingText());
PopupDepressedEffect(); PopupDepressedEffect();
Invoke(nameof(PopupBanner), 0.3f); // 0.3초 후에 배너 효과 실행 Invoke(nameof(PopupBanner), 0.3f);
} }
protected override void ShowPanel() protected override void ShowPanel()
@ -38,6 +38,8 @@ public class LoseEffectController : EffectController
private IEnumerator AnimateCharacterEyes() private IEnumerator AnimateCharacterEyes()
{ {
if (!gameObject.activeInHierarchy) yield return null; // 게임 오브젝트가 비활성화 상태면 실행 안 함
while (!cancellationTokenSource.IsCancellationRequested) while (!cancellationTokenSource.IsCancellationRequested)
{ {
characterOpenEyes.SetActive(false); characterOpenEyes.SetActive(false);
@ -57,6 +59,7 @@ public class LoseEffectController : EffectController
private void PopupBanner() private void PopupBanner()
{ {
if (!gameObject.activeInHierarchy) return; // 게임 오브젝트가 비활성화 상태면 실행 안 함
characterCloseEyes.SetActive(true); characterCloseEyes.SetActive(true);
characterOpenEyes.SetActive(false); characterOpenEyes.SetActive(false);
// 초기 크기 및 위치 설정 // 초기 크기 및 위치 설정
@ -84,8 +87,8 @@ public class LoseEffectController : EffectController
.SetDelay(0.2f) // 살짝 더 길게 흔들도록 설정 .SetDelay(0.2f) // 살짝 더 길게 흔들도록 설정
.OnComplete(() => .OnComplete(() =>
{ {
// 애니메이션이 끝난 후 눈 깜빡이는 효과 실행 if (gameObject.activeInHierarchy) // 실행 전에 다시 확인
StartCoroutine(AnimateCharacterEyes()); StartCoroutine(AnimateCharacterEyes()); // 애니메이션이 끝난 후 눈 깜빡이는 효과 실행
}); });
} }

View File

@ -38,6 +38,8 @@ public class RatingDownEffectController : EffectController
private IEnumerator AnimateCharacterEyes() private IEnumerator AnimateCharacterEyes()
{ {
if (!gameObject.activeInHierarchy) yield return null; // 게임 오브젝트가 비활성화 상태면 실행 안 함
while (!cancellationTokenSource.IsCancellationRequested) while (!cancellationTokenSource.IsCancellationRequested)
{ {
characterOpenEyes.SetActive(false); characterOpenEyes.SetActive(false);
@ -57,6 +59,8 @@ public class RatingDownEffectController : EffectController
private void PopupBanner() private void PopupBanner()
{ {
if (!gameObject.activeInHierarchy) return; // 게임 오브젝트가 비활성화 상태면 실행 안 함
characterCloseEyes.SetActive(true); characterCloseEyes.SetActive(true);
characterOpenEyes.SetActive(false); characterOpenEyes.SetActive(false);
// 초기 크기 및 위치 설정 // 초기 크기 및 위치 설정
@ -84,13 +88,15 @@ public class RatingDownEffectController : EffectController
.SetDelay(0.2f) // 살짝 더 길게 흔들도록 설정 .SetDelay(0.2f) // 살짝 더 길게 흔들도록 설정
.OnComplete(() => .OnComplete(() =>
{ {
// 애니메이션이 끝난 후 눈 깜빡이는 효과 실행 if (gameObject.activeInHierarchy)
StartCoroutine(AnimateCharacterEyes()); StartCoroutine(AnimateCharacterEyes()); // 애니메이션이 끝난 후 눈 깜빡이는 효과 실행
}); });
} }
private void PopupDepressedEffect() private void PopupDepressedEffect()
{ {
if (!gameObject.activeInHierarchy) return; // 게임 오브젝트가 비활성화 상태면 실행 안 함
depressedEffect.SetActive(true); depressedEffect.SetActive(true);
RectTransform rectTransform = depressedEffect.GetComponent<RectTransform>(); RectTransform rectTransform = depressedEffect.GetComponent<RectTransform>();
if (rectTransform != null) if (rectTransform != null)

View File

@ -50,6 +50,8 @@ public class RatingUpEffectController : EffectController
private void PopupObject() private void PopupObject()
{ {
if (!gameObject.activeInHierarchy) return; // 게임 오브젝트가 비활성화 상태면 실행 안 함
characterImg.SetActive(true); characterImg.SetActive(true);
// 초기 크기 및 위치 설정 // 초기 크기 및 위치 설정
@ -79,12 +81,16 @@ public class RatingUpEffectController : EffectController
private void ScaleUpSparkles() private void ScaleUpSparkles()
{ {
if (!gameObject.activeInHierarchy) return; // 게임 오브젝트가 비활성화 상태면 실행 안 함
// 스파클 효과 실행 // 스파클 효과 실행
StartCoroutine(ScaleUpSparklesCoroutine()); StartCoroutine(ScaleUpSparklesCoroutine());
} }
private IEnumerator ScaleUpSparklesCoroutine() private IEnumerator ScaleUpSparklesCoroutine()
{ {
if (!gameObject.activeInHierarchy) yield return null; // 게임 오브젝트가 비활성화 상태면 실행 안 함
while (!cancellationTokenSource.IsCancellationRequested) while (!cancellationTokenSource.IsCancellationRequested)
{ {
// 각 스파클 효과 실행 // 각 스파클 효과 실행
@ -97,6 +103,8 @@ public class RatingUpEffectController : EffectController
private IEnumerator ScaleUpEffectCoroutine(GameObject[] effectArray) private IEnumerator ScaleUpEffectCoroutine(GameObject[] effectArray)
{ {
if (!gameObject.activeInHierarchy) yield return null; // 게임 오브젝트가 비활성화 상태면 실행 안 함
foreach (GameObject effect in effectArray) foreach (GameObject effect in effectArray)
{ {
effect.transform.localScale = Vector3.zero; effect.transform.localScale = Vector3.zero;

View File

@ -13,11 +13,9 @@ public class WinEffectController : EffectController
protected override string fullText => "승리했습니다!"; protected override string fullText => "승리했습니다!";
public override void ShowEffect(OnEffectPanelEnded onEffectPanelEnd) public override void ShowEffect(OnEffectPanelEnded onEffectPanelEnd)
{ {
AudioManager.Instance.PlayWinSound(); //사운드 추가 AudioManager.Instance.PlayWinSound(); // 사운드 추가
gameObject.SetActive(true); gameObject.SetActive(true);
cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource = new CancellationTokenSource();
onEffectPanelEnded = onEffectPanelEnd; onEffectPanelEnded = onEffectPanelEnd;
@ -50,6 +48,8 @@ public class WinEffectController : EffectController
private void PopupObject() private void PopupObject()
{ {
if (!gameObject.activeInHierarchy) return; // 게임 오브젝트가 비활성화 상태면 실행 안 함
characterImg.SetActive(true); characterImg.SetActive(true);
// 초기 크기 및 위치 설정 // 초기 크기 및 위치 설정
@ -79,12 +79,16 @@ public class WinEffectController : EffectController
private void ScaleUpSparkles() private void ScaleUpSparkles()
{ {
if (!gameObject.activeInHierarchy) return; // 게임 오브젝트가 비활성화 상태면 실행 안 함
// 스파클 효과 실행 // 스파클 효과 실행
StartCoroutine(ScaleUpSparklesCoroutine()); StartCoroutine(ScaleUpSparklesCoroutine());
} }
private IEnumerator ScaleUpSparklesCoroutine() private IEnumerator ScaleUpSparklesCoroutine()
{ {
if (!gameObject.activeInHierarchy) yield return null; // 게임 오브젝트가 비활성화 상태면 실행 안 함
while (!cancellationTokenSource.IsCancellationRequested) while (!cancellationTokenSource.IsCancellationRequested)
{ {
// 각 스파클 효과 실행 // 각 스파클 효과 실행