From b613913d51f612400aff5cd2a4e1feef204c90cd Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 20 Aug 2014 14:42:42 +0100 Subject: [PATCH] Split SetView into MoveToView and FadeToView --- Assets/Fungus/Camera/Commands/FadeToView.cs | 68 +++++++++++++ .../{SetView.cs.meta => FadeToView.cs.meta} | 2 +- Assets/Fungus/Camera/Commands/MoveToView.cs | 55 +++++++++++ .../Fungus/Camera/Commands/MoveToView.cs.meta | 8 ++ Assets/Fungus/Camera/Commands/SetView.cs | 92 ------------------ .../Fungus/Camera/Scripts/CameraController.cs | 1 + Assets/Shuttle/ShuttleGame.unity | Bin 85940 -> 87724 bytes 7 files changed, 133 insertions(+), 93 deletions(-) create mode 100644 Assets/Fungus/Camera/Commands/FadeToView.cs rename Assets/Fungus/Camera/Commands/{SetView.cs.meta => FadeToView.cs.meta} (78%) create mode 100644 Assets/Fungus/Camera/Commands/MoveToView.cs create mode 100644 Assets/Fungus/Camera/Commands/MoveToView.cs.meta delete mode 100644 Assets/Fungus/Camera/Commands/SetView.cs 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 0466e4970ad9dbc0e7ef0b1fb06b1ed9d857ec9b..d79160d6c47f09e7c9b37da122af47c1ae2363e7 100644 GIT binary patch delta 2116 zcmb7^eN0T?I;9Tn|29-xxr|W0cF5o6kS<|K%g542nb_?7J*;}S_oe;W+2l@ z)J>KXy)2nhqFFF9EtaI15W|d-MWbSL1``t*L&Z#lvGL))@VT_bbNiovoSfd@^W5h> z=RN0kbU;3QS*|1G!H0yF4HH5F@OuI?Nl8deNUl#J4>vY8!ts2YSzn9&pSQM>+O`%e%ZPe}^+bhJEmLJ^*_9p*o7kmdpGRrfy{KLE zQD#k0J1_a43;&<*usCffjbY0CJ#-&S%-_SF(S|Ww`gV2(b06mSv>KM3qEgjcYwJqt zI$PUX>WBi%)^Dz3IV_$2BW}RCO;`1$sujXI_SJ& zbO8P5+}h5P!l4vG?%;J9xHxoR_Jf4f;`gd&UD03)W<^3_8X>t*Ry;}!lztz!4{Qc3 zi}S^T#jp`1*bIam;*@wO4j-lmTLR+~62J_ME~t&2>4ccLghVJ~V0>y4*t(A|c{8C% zOn8it5hQrKW;*z4apL2IG=h20=Lnb`j6cmxuuwL*pzgAxn0T7rlgokON!NiV>--CE>@E|95iv`wc+-iPZ$H5ZW_eki?lPYpIM^%XOx?5uf7-L>wc z4CD?r78Xbo>|jG+{JM$;%uVD;sjnEU9E|sU=Qw0@`1q#46os30e~;{?7XRYf?02=yK;-A$|)#zuot;Y*9aEzl>2($_FT~> zuznx*9GDVi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