Browse Source

Merge pull request #343 from FungusGames/stop-previous-itweens

Fixed iTween commands on the same gameobject can conflict #342
master
Chris Gregan 9 years ago
parent
commit
22ecada919
  1. 16
      Assets/Fungus/iTween/Scripts/Commands/iTweenCommand.cs

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

@ -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,11 +44,14 @@ namespace Fungus
return;
}
// Force any existing iTweens on this target object to complete immediately
iTween[] tweens = targetObject.GetComponents<iTween>();
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<iTween>();
foreach (iTween tween in tweens) {
tween.time = 0;
tween.SendMessage("Update");
}
}
DoTween();

Loading…
Cancel
Save