From c6674aae45467e80112d56fb9380ab11272e7803 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 13 Jan 2016 15:56:11 +0000 Subject: [PATCH] Fixed iTween commands on the same gameobject can conflict #342 The fix is to make the stopping behaviour option via a property --- .../iTween/Scripts/Commands/iTweenCommand.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Assets/Fungus/iTween/Scripts/Commands/iTweenCommand.cs b/Assets/Fungus/iTween/Scripts/Commands/iTweenCommand.cs index b99dfa43..25d715f2 100644 --- a/Assets/Fungus/iTween/Scripts/Commands/iTweenCommand.cs +++ b/Assets/Fungus/iTween/Scripts/Commands/iTweenCommand.cs @@ -11,7 +11,7 @@ namespace Fungus Y, Z } - + public abstract class iTweenCommand : Command { [Tooltip("Target game object to apply the Tween to")] @@ -30,6 +30,9 @@ namespace Fungus [Tooltip("The type of loop to apply once the animation has completed")] public iTween.LoopType loopType = iTween.LoopType.none; + [Tooltip("Stop any previously added iTweens on this object before adding this iTween")] + public bool stopPreviousTweens = false; + [Tooltip("Wait until the tween has finished before executing the next command")] public bool waitUntilFinished = true; @@ -41,15 +44,18 @@ namespace Fungus return; } - // Force any existing iTweens on this target object to complete immediately - iTween[] tweens = targetObject.GetComponents(); - foreach (iTween tween in tweens) { - tween.time = 0; - tween.SendMessage("Update"); + if (stopPreviousTweens) + { + // Force any existing iTweens on this target object to complete immediately + iTween[] tweens = targetObject.GetComponents(); + foreach (iTween tween in tweens) { + tween.time = 0; + tween.SendMessage("Update"); + } } DoTween(); - + if (!waitUntilFinished) { Continue(); @@ -80,7 +86,7 @@ namespace Fungus return targetObject.name + " over " + duration + " seconds"; } - + public override Color GetButtonColor() { return new Color32(233, 163, 180, 255);