diff --git a/Assets/Fungus/Camera/Commands/FadeToView.cs b/Assets/Fungus/Camera/Commands/FadeToView.cs new file mode 100644 index 00000000..3568d98d --- /dev/null +++ b/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 ""; + } + else + { + return "Fade to " + targetView.name; + } + } + } + +} \ No newline at end of file diff --git a/Assets/Fungus/Camera/Commands/SetView.cs.meta b/Assets/Fungus/Camera/Commands/FadeToView.cs.meta similarity index 78% rename from Assets/Fungus/Camera/Commands/SetView.cs.meta rename to Assets/Fungus/Camera/Commands/FadeToView.cs.meta index ee89295e..c4c18446 100644 --- a/Assets/Fungus/Camera/Commands/SetView.cs.meta +++ b/Assets/Fungus/Camera/Commands/FadeToView.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8b3057c17923c47bbbbf6dd0d8ecef99 +guid: 437f9a4e3dbc647f9bdce95308418bff MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/Assets/Fungus/Camera/Commands/MoveToView.cs b/Assets/Fungus/Camera/Commands/MoveToView.cs new file mode 100644 index 00000000..4fac7f3d --- /dev/null +++ b/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 ""; + } + else + { + return "Move to " + targetView.name; + } + } + } + +} \ No newline at end of file diff --git a/Assets/Fungus/Camera/Commands/MoveToView.cs.meta b/Assets/Fungus/Camera/Commands/MoveToView.cs.meta new file mode 100644 index 00000000..22315d01 --- /dev/null +++ b/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: diff --git a/Assets/Fungus/Camera/Commands/SetView.cs b/Assets/Fungus/Camera/Commands/SetView.cs deleted file mode 100644 index d44a0b67..00000000 --- a/Assets/Fungus/Camera/Commands/SetView.cs +++ /dev/null @@ -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 = ""; - } - else - { - description += targetView.name; - } - - return description; - } - } - -} \ No newline at end of file diff --git a/Assets/Fungus/Camera/Scripts/CameraController.cs b/Assets/Fungus/Camera/Scripts/CameraController.cs index fbf0fa7a..b870305b 100644 --- a/Assets/Fungus/Camera/Scripts/CameraController.cs +++ b/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 { diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 0466e497..d79160d6 100644 Binary files a/Assets/Shuttle/ShuttleGame.unity and b/Assets/Shuttle/ShuttleGame.unity differ