Interrupting and Chaining - rmfandyplayz/UnityUIAnimationTools GitHub Wiki

What happens when one animation starts while another is running, and how to play animations one after another.

Interrupt Others

Every animation has an Interrupt Others tick box, on by default. While it's ticked, playing that animation ends every other animation on the same player first. So playing Show and then Hide straight after leaves only Hide running, which is almost always what you want.

Untick it for something that should play on top of the others, like a looping attention pulse.

How the others end

Two buttons beside the tick choose what happens to the animations it ends:

Interrupt Others    ✔  [COMPLETE] [REPORT]

First button:

  • COMPLETE (the default): they jump to their end first, so this animation starts from where they were heading. Leave a button halfway through its hover-in, and the hover-out starts from the fully hovered state.
  • STOP: they stop where they are, and this animation starts from there. Leave halfway through a hover-in, and the hover-out starts from halfway.

Second button (only used with COMPLETE):

  • REPORT (the default): the ended animation counts as finished. Its On Complete runs.
  • SILENT: it only jumps to its end. On Complete doesn't run.

Good to know:

  • The setting belongs to the animation doing the interrupting. A Hover set to COMPLETE completes whatever it interrupts, whatever that animation's own buttons say.
  • Jumping to the end runs any Set Active steps it skipped, but not the sounds, so you don't get every skipped sound at once.
  • An endless loop (Loops -1) has no end, so it always just stops where it is.
  • Playing an animation that's already running always restarts it from where it is, whatever its buttons say. They're only about the others. (A punch or shake is put back where it started first.)

Note

Animations made before these two buttons existed read STOP, which is exactly how they always behaved. Nothing already in your scenes changes until you click.

Chaining animations

Put a PlayAnimation call in one animation's On Complete to play the next one when it finishes. No code needed. See From UnityEvents.

  • Stopping a chain stops it dead. On Complete only runs when an animation finishes on its own, so a stopped link never starts the next one.
  • An animation that plays itself from its On Complete restarts cleanly. That's a loop, though, and Loops -1 says it better.
  • Interrupting a chain with COMPLETE REPORT runs the interrupted animation's On Complete, which tries to start the next link. That link is stopped straight away, so the interrupting animation still ends up the only one running, but anything else that On Complete does has happened. Use SILENT if it shouldn't.

When objects are turned off or destroyed

  • Kill On Disable (on the player, on by default): turning the object off stops its animations, loops included, and their On Complete doesn't run. The next Play starts cleanly. Untick it to let animations keep running while the object is off.
  • Destroying the object or changing scenes stops everything cleanly. Nothing is left running in the background.
  • Use Unscaled Time (on by default) keeps UI animating while the game is paused.
Under the hood
  • An animation releases its sequence before firing its callbacks. So when an On Complete plays the next animation, and that animation's Interrupt Others tries to end the one whose callback is running, there's nothing left to interrupt. That's what makes chaining safe.
  • Why an already-running animation always restarts from where it is: completing it first would jump it to its own end, and a step without a From would then have nowhere left to go, so a replay would visibly do nothing. The consequence: a count-up replayed mid-count carries on from the number on screen. Keep the real total in code and SetTo it.
  • Completing uses Sequence.Complete(true), never DOTween's Kill(complete: true). Measured in play mode, Kill(complete: true) reaches the end values and fires On Complete, but skips callbacks still ahead in the sequence, so a Set Active step never ran. The sounds are silenced separately while completing.
  • When completing with REPORT, everything running is noted before any of it is completed, then anything the On Completes started is swept away. Otherwise a chain would complete to its end or not depending on list order.
  • Stop(name, complete: true) and StopAll(true) finish the same way as COMPLETE REPORT. StopAll(true) also stops anything their On Complete starts, so nothing is left running.
  • A new animation starts at COMPLETE REPORT, but only a brand-new, never-filled animation. Unity gives an old animation missing these fields false, which reads STOP, so old data keeps its old behaviour.
  • Sequences are linked to the GameObject with SetLink and also killed in OnDestroy.
⚠️ **GitHub.com Fallback** ⚠️