Browse Source

Improved Camera fade wait logic

Early out if already at target alpha
master
chrisgregan 11 years ago
parent
commit
5092e82eee
  1. 8
      Assets/Fungus/Scripts/CameraController.cs

8
Assets/Fungus/Scripts/CameraController.cs

@ -62,6 +62,13 @@ namespace Fungus
float startAlpha = Game.GetInstance().fadeAlpha;
float timer = 0;
// If already at the target alpha then complete immediately
if (startAlpha == targetAlpha)
{
yield return null;
}
else
{
while (timer < fadeDuration)
{
float t = timer / fadeDuration;
@ -72,6 +79,7 @@ namespace Fungus
Game.GetInstance().fadeAlpha = Mathf.Lerp(startAlpha, targetAlpha, t);
yield return null;
}
}
Game.GetInstance().fadeAlpha = targetAlpha;

Loading…
Cancel
Save