From f1dad48153e9aab76e16bb66d5e4d4c8f464ef7a Mon Sep 17 00:00:00 2001 From: Tim Nugent Date: Wed, 6 Apr 2022 14:27:16 +1000 Subject: [PATCH 1/2] Tweaked line view. Fixes #161 Fixes #153 --- Runtime/Views/LineView.cs | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Runtime/Views/LineView.cs b/Runtime/Views/LineView.cs index 18ee96be..8bccd875 100644 --- a/Runtime/Views/LineView.cs +++ b/Runtime/Views/LineView.cs @@ -163,7 +163,7 @@ public static IEnumerator Typewriter(TextMeshProUGUI text, float lettersPerSecon { // Show everything and return text.maxVisibleCharacters = characterCount; - stopToken.Complete(); + stopToken?.Complete(); yield break; } @@ -362,7 +362,7 @@ public class LineView : DialogueViewBase internal GameObject continueButton = null; /// - /// The amount of time to wait after any lin + /// The amount of time to wait after any line /// [SerializeField] [Min(0)] @@ -403,7 +403,7 @@ public class LineView : DialogueViewBase /// Effects.CoroutineInterruptToken currentStopToken = new Effects.CoroutineInterruptToken(); - private void Start() + private void Awake() { canvasGroup.alpha = 0; canvasGroup.blocksRaycasts = false; @@ -422,8 +422,11 @@ public override void DismissLine(Action onDismissalComplete) StartCoroutine(DismissLineInternal(onDismissalComplete)); } - private IEnumerator DismissLineInternal(Action onDismissalComplete) { - + private IEnumerator DismissLineInternal(Action onDismissalComplete) + { + // disabling interaction temporarily while dismissing the line + // we don't want people to interrupt a dismissal + var interactable = canvasGroup.interactable; canvasGroup.interactable = false; // If we're using a fade effect, run it, and wait for it to finish. @@ -435,6 +438,8 @@ private IEnumerator DismissLineInternal(Action onDismissalComplete) { canvasGroup.alpha = 0; canvasGroup.blocksRaycasts = false; + // turning interaction back on, if it needs it + canvasGroup.interactable = interactable; onDismissalComplete(); } @@ -565,6 +570,10 @@ IEnumerator PresentLine() // it to finish. if (useTypewriterEffect) { + // setting the canvas all back to its defaults because if we didn't also fade we don't have anything visible + canvasGroup.alpha = 1f; + canvasGroup.interactable = true; + canvasGroup.blocksRaycasts = true; yield return StartCoroutine( Effects.Typewriter( lineText, @@ -594,6 +603,7 @@ IEnumerator PresentLine() // Our view should at be at full opacity. canvasGroup.alpha = 1f; + canvasGroup.blocksRaycasts = true; // Show the continue button, if we have one. if (continueButton != null) @@ -635,16 +645,19 @@ public override void UserRequestedViewAdvancement() return; } + // we may want to change this later so the interrupted + // animation coroutine is what actually interrupts + // for now this is fine. // Is an animation running that we can stop? - if (currentStopToken.CanInterrupt) { + if (currentStopToken.CanInterrupt) + { // Stop the current animation, and skip to the end of whatever // started it. currentStopToken.Interrupt(); - } else { - // No animation is currently running. Signal that we want to - // interrupt the line instead. - requestInterrupt?.Invoke(); } + // No animation is now running. Signal that we want to + // interrupt the line instead. + requestInterrupt?.Invoke(); } /// From 336ca10127751e8960d83bb6da6fc6b8cff4a7f7 Mon Sep 17 00:00:00 2001 From: Tim Nugent Date: Wed, 6 Apr 2022 14:30:22 +1000 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ecc044c..6f01c59a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ This means in many situations where either the l-value or r-value of an expressi Additionally now functions tagged with the `YarnFunction` attribute are sent along to the compiler so that they can be used to inform values. The upside of this is in situations like `<>` if either `$cats` is declared or `get_cats` is tagged as a `YarnFunction` there won't be an error anymore. +- Line view should no longer have unusual interactions around enabling and disabling different effects (#161 and #153). + ### Removed ## [2.1.0] 2022-02-17