Browse Source

Fixed iTween commands on the same gameobject can conflict #342

The fix is to make the stopping behaviour option via a property
master
chrisgregan 9 years ago
parent
commit
c6674aae45
  1. 22
      Assets/Fungus/iTween/Scripts/Commands/iTweenCommand.cs

22
Assets/Fungus/iTween/Scripts/Commands/iTweenCommand.cs

@ -11,7 +11,7 @@ namespace Fungus
Y, Y,
Z Z
} }
public abstract class iTweenCommand : Command public abstract class iTweenCommand : Command
{ {
[Tooltip("Target game object to apply the Tween to")] [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")] [Tooltip("The type of loop to apply once the animation has completed")]
public iTween.LoopType loopType = iTween.LoopType.none; 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")] [Tooltip("Wait until the tween has finished before executing the next command")]
public bool waitUntilFinished = true; public bool waitUntilFinished = true;
@ -41,15 +44,18 @@ namespace Fungus
return; return;
} }
// Force any existing iTweens on this target object to complete immediately if (stopPreviousTweens)
iTween[] tweens = targetObject.GetComponents<iTween>(); {
foreach (iTween tween in tweens) { // Force any existing iTweens on this target object to complete immediately
tween.time = 0; iTween[] tweens = targetObject.GetComponents<iTween>();
tween.SendMessage("Update"); foreach (iTween tween in tweens) {
tween.time = 0;
tween.SendMessage("Update");
}
} }
DoTween(); DoTween();
if (!waitUntilFinished) if (!waitUntilFinished)
{ {
Continue(); Continue();
@ -80,7 +86,7 @@ namespace Fungus
return targetObject.name + " over " + duration + " seconds"; return targetObject.name + " over " + duration + " seconds";
} }
public override Color GetButtonColor() public override Color GetButtonColor()
{ {
return new Color32(233, 163, 180, 255); return new Color32(233, 163, 180, 255);

Loading…
Cancel
Save