Browse Source

Control fade out effect in Fade To View command #109

master
chrisgregan 10 years ago
parent
commit
4f0e21d0da
  1. 22
      Assets/Fungus/Camera/Scripts/CameraController.cs
  2. 5
      Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs

22
Assets/Fungus/Camera/Scripts/CameraController.cs

@ -131,19 +131,33 @@ namespace Fungus
/**
* Fade out, move camera to view and then fade back in.
*/
public virtual void FadeToView(View view, float fadeDuration, Action fadeAction)
public virtual void FadeToView(View view, float fadeDuration, bool fadeOut, Action fadeAction)
{
swipePanActive = false;
fadeAlpha = 0f;
float outDuration;
float inDuration;
if (fadeOut)
{
outDuration = fadeDuration / 2f;
inDuration = fadeDuration / 2f;
}
else
{
outDuration = 0;
inDuration = fadeDuration;
}
// Fade out
Fade(1f, fadeDuration / 2f, delegate {
Fade(1f, outDuration, delegate {
// Snap to new view
PanToPosition(view.transform.position, view.transform.rotation, view.viewSize, 0f, null);
// Fade in
Fade(0f, fadeDuration / 2f, delegate {
Fade(0f, inDuration, delegate {
if (fadeAction != null)
{
fadeAction();

5
Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs

@ -13,6 +13,9 @@ namespace Fungus
[Tooltip("Time for fade effect to complete")]
public float duration = 1f;
[Tooltip("Fade from fully visible to opaque at start of fade")]
public bool fadeOut = true;
[Tooltip("View to transition to when Fade is complete")]
public View targetView;
@ -49,7 +52,7 @@ namespace Fungus
cameraController.screenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32);
}
cameraController.FadeToView(targetView, duration, delegate {
cameraController.FadeToView(targetView, duration, fadeOut, delegate {
if (waitUntilFinished)
{
cameraController.waiting = false;

Loading…
Cancel
Save