From 31f9d86d7e64e781a53a6c91b16f958652345bd8 Mon Sep 17 00:00:00 2001 From: Christopher Date: Mon, 26 Sep 2016 14:30:16 +0100 Subject: [PATCH] Reverted ICameraController interface --- Assets/Fungus/Scripts/Commands/FadeScreen.cs | 2 +- Assets/Fungus/Scripts/Commands/FadeToView.cs | 2 +- Assets/Fungus/Scripts/Commands/MoveToView.cs | 2 +- Assets/Fungus/Scripts/Commands/StartSwipe.cs | 2 +- Assets/Fungus/Scripts/Commands/StopSwipe.cs | 2 +- .../Scripts/Components/CameraController.cs | 33 +++++++++++-- Assets/Fungus/Scripts/Components/Writer.cs | 2 +- .../Scripts/Interfaces/ICameraController.cs | 49 ------------------- .../Interfaces/ICameraController.cs.meta | 12 ----- 9 files changed, 35 insertions(+), 71 deletions(-) delete mode 100644 Assets/Fungus/Scripts/Interfaces/ICameraController.cs delete mode 100644 Assets/Fungus/Scripts/Interfaces/ICameraController.cs.meta diff --git a/Assets/Fungus/Scripts/Commands/FadeScreen.cs b/Assets/Fungus/Scripts/Commands/FadeScreen.cs index 877d6dbe..ff86f94a 100644 --- a/Assets/Fungus/Scripts/Commands/FadeScreen.cs +++ b/Assets/Fungus/Scripts/Commands/FadeScreen.cs @@ -33,7 +33,7 @@ namespace Fungus.Commands public override void OnEnter() { - ICameraController cameraController = CameraController.GetInstance(); + var cameraController = CameraController.GetInstance(); if (fadeTexture) { diff --git a/Assets/Fungus/Scripts/Commands/FadeToView.cs b/Assets/Fungus/Scripts/Commands/FadeToView.cs index d653df4f..b3be3249 100644 --- a/Assets/Fungus/Scripts/Commands/FadeToView.cs +++ b/Assets/Fungus/Scripts/Commands/FadeToView.cs @@ -65,7 +65,7 @@ namespace Fungus.Commands return; } - ICameraController cameraController = CameraController.GetInstance(); + var cameraController = CameraController.GetInstance(); if (fadeTexture) { diff --git a/Assets/Fungus/Scripts/Commands/MoveToView.cs b/Assets/Fungus/Scripts/Commands/MoveToView.cs index 18f2a5c7..9055f551 100644 --- a/Assets/Fungus/Scripts/Commands/MoveToView.cs +++ b/Assets/Fungus/Scripts/Commands/MoveToView.cs @@ -56,7 +56,7 @@ namespace Fungus.Commands return; } - ICameraController cameraController = CameraController.GetInstance(); + var cameraController = CameraController.GetInstance(); Vector3 targetPosition = targetView.transform.position; Quaternion targetRotation = targetView.transform.rotation; diff --git a/Assets/Fungus/Scripts/Commands/StartSwipe.cs b/Assets/Fungus/Scripts/Commands/StartSwipe.cs index f7d311b7..3bd6d6b5 100644 --- a/Assets/Fungus/Scripts/Commands/StartSwipe.cs +++ b/Assets/Fungus/Scripts/Commands/StartSwipe.cs @@ -51,7 +51,7 @@ namespace Fungus.Commands return; } - ICameraController cameraController = CameraController.GetInstance(); + var cameraController = CameraController.GetInstance(); cameraController.StartSwipePan(targetCamera, viewA, viewB, duration, speedMultiplier, () => Continue() ); } diff --git a/Assets/Fungus/Scripts/Commands/StopSwipe.cs b/Assets/Fungus/Scripts/Commands/StopSwipe.cs index bc6b5f94..69706372 100644 --- a/Assets/Fungus/Scripts/Commands/StopSwipe.cs +++ b/Assets/Fungus/Scripts/Commands/StopSwipe.cs @@ -16,7 +16,7 @@ namespace Fungus.Commands { public override void OnEnter() { - ICameraController cameraController = CameraController.GetInstance(); + var cameraController = CameraController.GetInstance(); cameraController.StopSwipePan(); diff --git a/Assets/Fungus/Scripts/Components/CameraController.cs b/Assets/Fungus/Scripts/Components/CameraController.cs index 23b35000..3ed376a5 100644 --- a/Assets/Fungus/Scripts/Components/CameraController.cs +++ b/Assets/Fungus/Scripts/Components/CameraController.cs @@ -9,7 +9,10 @@ using Fungus; namespace Fungus { - public class CameraController : MonoBehaviour, ICameraController + /// + /// Controller for main camera.Supports several types of camera transition including snap, pan & fade. + /// + public class CameraController : MonoBehaviour { [Tooltip("Full screen texture used for screen fade effect.")] [SerializeField] protected Texture2D screenFadeTexture; @@ -48,13 +51,13 @@ namespace Fungus protected Dictionary storedViews = new Dictionary(); - protected static ICameraController instance; + protected static CameraController instance; /// /// Returns the CameraController singleton instance. /// Will create a CameraController game object if none currently exists. /// - static public ICameraController GetInstance() + static public CameraController GetInstance() { if (instance == null) { @@ -361,15 +364,25 @@ namespace Fungus return cameraSize; } - #region ICameraController implementation + #region Public methods + /// + /// Full screen texture used for screen fade effect. + /// + /// The screen fade texture. public Texture2D ScreenFadeTexture { set { screenFadeTexture = value; } } + /// + /// Perform a fullscreen fade over a duration. + /// public virtual void Fade(float targetAlpha, float fadeDuration, Action fadeAction) { StartCoroutine(FadeInternal(targetAlpha, fadeDuration, fadeAction)); } + /// + /// Fade out, move camera to view and then fade back in. + /// public virtual void FadeToView(Camera camera, View view, float fadeDuration, bool fadeOut, Action fadeAction) { swipePanActive = false; @@ -405,11 +418,17 @@ namespace Fungus }); } + /// + /// Stop all camera tweening. + /// public virtual void Stop() { StopAllCoroutines(); } + /// + /// Moves camera from current position to a target position over a period of time. + /// public virtual void PanToPosition(Camera camera, Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, Action arriveAction) { if (camera == null) @@ -443,6 +462,9 @@ namespace Fungus } } + /// + /// Activates swipe panning mode. The player can pan the camera within the area between viewA & viewB. + /// public virtual void StartSwipePan(Camera camera, View viewA, View viewB, float duration, float speedMultiplier, Action arriveAction) { if (camera == null) @@ -472,6 +494,9 @@ namespace Fungus }); } + /// + /// Deactivates swipe panning mode. + /// public virtual void StopSwipePan() { swipePanActive = false; diff --git a/Assets/Fungus/Scripts/Components/Writer.cs b/Assets/Fungus/Scripts/Components/Writer.cs index 836526f4..afe63587 100644 --- a/Assets/Fungus/Scripts/Components/Writer.cs +++ b/Assets/Fungus/Scripts/Components/Writer.cs @@ -716,7 +716,7 @@ namespace Fungus protected virtual void Flash(float duration) { - ICameraController cameraController = CameraController.GetInstance(); + var cameraController = CameraController.GetInstance(); cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32); cameraController.Fade(1f, duration, delegate { cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(new Color(1f,1f,1f,1f), 32, 32); diff --git a/Assets/Fungus/Scripts/Interfaces/ICameraController.cs b/Assets/Fungus/Scripts/Interfaces/ICameraController.cs deleted file mode 100644 index 977d20da..00000000 --- a/Assets/Fungus/Scripts/Interfaces/ICameraController.cs +++ /dev/null @@ -1,49 +0,0 @@ -// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). -// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) - -using UnityEngine; - -namespace Fungus -{ - /// - /// Controller for main camera.Supports several types of camera transition including snap, pan & fade. - /// - public interface ICameraController - { - /// - /// Full screen texture used for screen fade effect. - /// - /// The screen fade texture. - Texture2D ScreenFadeTexture { set; } - - /// - /// Perform a fullscreen fade over a duration. - /// - void Fade(float targetAlpha, float fadeDuration, System.Action fadeAction); - - /// - /// Fade out, move camera to view and then fade back in. - /// - void FadeToView(Camera camera, View view, float fadeDuration, bool fadeOut, System.Action fadeAction); - - /// - /// Stop all camera tweening. - /// - void Stop(); - - /// - /// Moves camera from current position to a target position over a period of time. - /// - void PanToPosition(Camera camera, Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, System.Action arriveAction); - - /// - /// Activates swipe panning mode. The player can pan the camera within the area between viewA & viewB. - /// - void StartSwipePan(Camera camera, View viewA, View viewB, float duration, float speedMultiplier, System.Action arriveAction); - - /// - /// Deactivates swipe panning mode. - /// - void StopSwipePan(); - } -} \ No newline at end of file diff --git a/Assets/Fungus/Scripts/Interfaces/ICameraController.cs.meta b/Assets/Fungus/Scripts/Interfaces/ICameraController.cs.meta deleted file mode 100644 index 43f258f6..00000000 --- a/Assets/Fungus/Scripts/Interfaces/ICameraController.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 182888cc7e1a0470c81e9ea6966d6fc6 -timeCreated: 1473431064 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: