Browse Source

Split SetView into MoveToView and FadeToView

master
chrisgregan 10 years ago
parent
commit
b613913d51
  1. 68
      Assets/Fungus/Camera/Commands/FadeToView.cs
  2. 2
      Assets/Fungus/Camera/Commands/FadeToView.cs.meta
  3. 55
      Assets/Fungus/Camera/Commands/MoveToView.cs
  4. 8
      Assets/Fungus/Camera/Commands/MoveToView.cs.meta
  5. 92
      Assets/Fungus/Camera/Commands/SetView.cs
  6. 1
      Assets/Fungus/Camera/Scripts/CameraController.cs
  7. BIN
      Assets/Shuttle/ShuttleGame.unity

68
Assets/Fungus/Camera/Commands/FadeToView.cs

@ -0,0 +1,68 @@
using UnityEngine;
using System;
using System.Collections;
namespace Fungus.Script
{
[CommandName("Fade To View")]
[HelpText("Fades the camera out and in again at a location specified by a View object.")]
public class FadeToView : FungusCommand
{
public float duration;
public Fungus.View targetView;
public bool waitUntilFinished = true;
public Color fadeColor = Color.black;
public Texture2D fadeTexture;
public override void OnEnter()
{
if (targetView == null)
{
Continue();
return;
}
CameraController cameraController = CameraController.GetInstance();
if (waitUntilFinished)
{
cameraController.waiting = true;
}
if (fadeTexture)
{
cameraController.screenFadeTexture = fadeTexture;
}
else
{
cameraController.screenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32);
}
cameraController.FadeToView(targetView, duration, delegate {
if (waitUntilFinished)
{
cameraController.waiting = false;
Continue();
}
});
if (!waitUntilFinished)
{
Continue();
}
}
public override string GetSummary()
{
if (targetView == null)
{
return "<no view selected>";
}
else
{
return "Fade to " + targetView.name;
}
}
}
}

2
Assets/Fungus/Camera/Commands/SetView.cs.meta → Assets/Fungus/Camera/Commands/FadeToView.cs.meta

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 8b3057c17923c47bbbbf6dd0d8ecef99
guid: 437f9a4e3dbc647f9bdce95308418bff
MonoImporter:
serializedVersion: 2
defaultReferences: []

55
Assets/Fungus/Camera/Commands/MoveToView.cs

@ -0,0 +1,55 @@
using UnityEngine;
using System;
using System.Collections;
namespace Fungus.Script
{
[CommandName("Move To View")]
[HelpText("Moves the camera to a location specified by a View object.")]
public class MoveToView : FungusCommand
{
public float duration;
public Fungus.View targetView;
public bool waitUntilFinished = true;
public override void OnEnter()
{
CameraController cameraController = CameraController.GetInstance();
if (waitUntilFinished)
{
cameraController.waiting = true;
}
Vector3 targetPosition = targetView.transform.position;
Quaternion targetRotation = targetView.transform.rotation;
float targetSize = targetView.viewSize;
cameraController.PanToPosition(targetPosition, targetRotation, targetSize, duration, delegate {
if (waitUntilFinished)
{
cameraController.waiting = false;
Continue();
}
});
if (!waitUntilFinished)
{
Continue();
}
}
public override string GetSummary()
{
if (targetView == null)
{
return "<no view selected>";
}
else
{
return "Move to " + targetView.name;
}
}
}
}

8
Assets/Fungus/Camera/Commands/MoveToView.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 45c952ea1ad444e479b570fa242679c5
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

92
Assets/Fungus/Camera/Commands/SetView.cs

@ -1,92 +0,0 @@
using UnityEngine;
using System;
using System.Collections;
namespace Fungus.Script
{
[CommandName("Set View")]
[HelpText("Moves the camera to a location specified by a View object. Supports Move and Fade transitions over a period of time.")]
public class SetView : FungusCommand
{
public enum Transition
{
Move,
Fade
}
public Transition transition;
public float duration;
public Fungus.View targetView;
public bool waitUntilFinished = true;
public Color fadeColor = Color.black;
public override void OnEnter()
{
CameraController cameraController = CameraController.GetInstance();
if (waitUntilFinished)
{
cameraController.waiting = true;
}
if (transition == Transition.Fade)
{
cameraController.screenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32);
cameraController.FadeToView(targetView, duration, delegate {
if (waitUntilFinished)
{
cameraController.waiting = false;
Continue();
}
});
}
else if (transition == Transition.Move)
{
Vector3 targetPosition = targetView.transform.position;
Quaternion targetRotation = targetView.transform.rotation;
float targetSize = targetView.viewSize;
cameraController.PanToPosition(targetPosition, targetRotation, targetSize, duration, delegate {
if (waitUntilFinished)
{
cameraController.waiting = false;
Continue();
}
});
}
if (!waitUntilFinished)
{
Continue();
}
}
public override string GetSummary()
{
string description = "";
switch (transition)
{
case Transition.Move:
description = "Move to ";
break;
case Transition.Fade:
description = "Fade to ";
break;
}
if (targetView == null)
{
description = "<no view selected>";
}
else
{
description += targetView.name;
}
return description;
}
}
}

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

@ -134,6 +134,7 @@ namespace Fungus
public void FadeToView(View view, float fadeDuration, Action fadeAction)
{
swipePanActive = false;
fadeAlpha = 1f;
// Fade out
Fade(0f, fadeDuration / 2f, delegate {

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save