Skip to content

Commit

Permalink
feat: fade out black screen
Browse files Browse the repository at this point in the history
  • Loading branch information
pyoneerC committed Sep 23, 2024
1 parent a2bd3e9 commit cd9b1e0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Assets/Scripts/WaterLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,27 @@ private IEnumerator FadeInBlackCanvas()
_isFadingIn = false;
}

private IEnumerator FadeOutBlackCanvas()
{
_isFadingIn = true;
const float duration = 6f;
var timeElapsed = 0f;

blackFadeImage.color = new Color(0, 0, 0, 1);

while (timeElapsed < duration)
{
timeElapsed += Time.deltaTime;
var alpha = Mathf.Clamp01(1 - (timeElapsed / duration)); // Fade out
blackFadeImage.color = new Color(0, 0, 0, alpha);
yield return null;
}

blackFadeImage.color = new Color(0, 0, 0, 0);
_isFadingIn = false;
}


private void EnterWater()
{
_isUnderwater = true;
Expand All @@ -213,6 +234,8 @@ private void ExitWater()

_audioSource.loop = false;
_audioSource.Stop();

StartCoroutine(FadeOutBlackCanvas());
}

private void HandleUnderwaterMovement()
Expand Down

0 comments on commit cd9b1e0

Please sign in to comment.