Using Signal Emitters in Timeline to Alter Playback — Unity
Objective: To learn how to make Playback adjustments using Signal Emitters in Unity’s Timeline.

By accessing our Playback controls from Timeline through code, we are able to create some runtime scenarios such as pausing a cinematic cutscene with the spacebar or holding down the Esc key to end the cutscene prematurely.
Let’s take a look at how to get this setup in your next game.
Setting up the Basic Scene
First we need to be able to access the Playback controls through our script, so let’s get this setup. I am going to be using option 2 to setup our signal emitter from this article, so we can look at a different approach to this.
I have a very basic scene, with a plane, and a prefab model/animation from mixamo. I have then created a PlayableDirector() component on this prefab, along with a new Timeline. I have then dragged the prefab into the Timeline window and selected ‘Signal Track’. This will automatically create a Signal Receiver component on the prefab.
At the same time I have dragged the animation for the model into the Timeline window and created an Animation Track so we can watch the dance pause when the signal emits.



Creating the Script
Let’s make this as basic as possible just to show it’s purpose.

First, we need to access the Playables namespace so we can access the built-in PlayableDirector class.
Then, we need to make the variable _playDirector visible in the Inspector so we can assign it by using the [SerializeField] class. Don’t forget to now go into the Inspector window and assign the prefab to this slot.
Next, let’s grab the component. Attach this script to your prefab. As the script is on our prefab, we can simply grab the component without having to find the game object first.
Lastly, let’s create a public method that is going to tell us in the Console window when it has triggered and also let’s use the built-in method for the PlayableDirector class that pauses Timeline.
Your prefab should now have all these components:

Setting up the Signal Emitter
If you are unsure how to get this setup, click on this article. Let’s place the Signal Emitter somewhere in the middle of the animation.

Let’s create a new Signal Asset for the ‘Emit Signal’ field in the Inspector for the newly created Signal Emitter.

Adding a Reaction to the Signal Receiver
Hit the ‘Add Reaction’ button, then where it says ‘No Function’, click on the drop down box and navigate your way to the public method that was created in the Playback script.

If you want to be able to see the game pause in the editor when pressing ‘Play’ in the Timeline window, then click this option. Otherwise you will always need to press the normal ‘Play’ button and watch it happen at runtime:

Let’s Test it!

Wonderful! Works a treat.
The Signal Receiver is reacting to the Signal Emitted and and behaving accordingly.
Let’s Get the Cutscene Going Again!
Let’s create some input for the player — By pressing the ‘F’ key during runtime, the player will be able to play the cutscene again using the PlayableDirectors class built-in Play() method.

