Since Timeline released in 2017.1, there has been a lot of [requests]( Timeline events? page-2#post-3313335) [for]( Timeline events? page-3#post-3366709) [events]( Timeline events? page-4#post-3598074). With good reason; it was something that was sorely missing. Some people implemented events through clips (by the way, thanks to everyone who offered their custom event implementation to the community), even if, in this use case, clips had their shortcomings.
Well, the Timeline team is proud to offer you an early Christmas present: signals are now available in 2019.1.0a11!
A new item has appeared: markers!
A marker is new item that can be added to a timeline. It is used to represent a point in time.
Markers can be added and manipulated on a timeline the same way as clips; selection, copy-paste, edit modes etc. should work. A marker also has a specialization, just like clips (Animation Clip, Activation Clip, Control Clip, etc.). In 2019.1, Timeline offers its first built-in marker: Signal Emitter marker.
What are signal emitters?
Signal emitters are used to trigger a change in state of the scene when the timeline passes a given point in time. We used the word signal instead of event because it supported the idea of âbroadcastâ while avoiding the confusion with the already existing Unity Event and Animation Event.
Where can I add a Signal Emitter?
A Signal Emitter can be added on the timeline and on tracks (with some restrictions).
- On the timeline: This is a new concept for this release. Signals can be added on the timeline itself. No tracks are needed in this case.
- On a track: Signals can also be added to any track, as long as the track accepts a binding. Weâve also introduced a new type of track, a Signal Track. This track accepts only signals but no clips.
Keep in mind that where you place a signal emitter will define how this signal is received. More on that later.
How does it work?
In order to properly set up signals on a timeline, you need three pieces: a Signal Asset, a Signal Emitter and a Signal Receiver.
- Signal Asset: This asset is the link between an emitter and a receiver. Basically, the Signal Asset acts as an identifier.
- Signal Emitter: A Signal Emitter is placed on the Timeline. It contains a reference to a Signal Asset. When played, if the current time is greater than the emitterâs time, the emitter is triggered; it will send its Signal Asset to a Signal Receiver.
- Signal Receiver: The Signal Receiver is a component that has a list of reactions, each of those reactions are bound to a Signal Asset. When a receiver is notified that a signal has been triggered, it will invoke the reaction bound to the corresponding Signal Asset.
The main idea that guided our design was to make the piece that sends the signals (the emitter) as independent as possible from the piece that listens and reacts to signals (the receiver). This design adds a lot of flexibility and is very powerful. Letâs see in details how all those pieces work together.
The Signal Emitter
-
Create a timeline. Then, click on the pin button near the edit modes button.
-
The Timeline Marker area is now displayed. Right-click in the area under the time ruler and choose Add Signal Emitter.
-
In the Signal Emitter inspector, click on Create Signal⌠to create a new Signal Asset to your project.
-
Still in the Signal Emitter inspector, click on Add Signal Receiver. The inspector should look like this:
The Add Signal Receiver button did the following:
- It added a new Signal Receiver component to the bound object. If the Signal Emitter is on a track, the component will be added to the trackâs bound object. If the Signal Emitter is on the Timeline (like I did in my example) then the Gameobject which owns PlayableDirector will have a new Signal Receiver component.
- It added a new reaction bound to the Signal Asset I just created.
I can then use the Unity Event UI to define what should be invoked when the Signal Emitter is triggered.
The important part is that the Signal Emitter inspector first shows you properties related to the Signal Emitter. It also displays, for your convenience, the Signal Receiver that will receive the signals.
The Retroactive property, when enabled, will trigger the signal if the timeline begins playing after the signalâs time.
The Emit Once property, when enabled, will trigger the signal only once when the timeline loops.
The Signal Receiver
Letâs take a look at the Signal Receiver component. Click on the Gameobject that owns the Signal Receiver.
It shows you nearly exactly what we saw previously; the Explosion signal is bound to an empty UnityEvent.
Letâs say we want to add a new Signal Asset. We can do it right here. Click the Add Reaction button. A new reaction was added, bound to nothing. Click on the dropdown and choose Create SignalâŚ
Here is my result after I created a new asset:
The Signal Receiver is now setup to invoke reactions when it receivers the Explosion and Load Scene signals.
If I go back to the Timeline, then I can add a Signal Emitter that either sends the Explosion or the Load Scene signals. I can also easily switch between the two.
So in a nutshell, how do I setup my first signal?
You need a grand total of 4 clicks:
- Right-click on a track which supports signals, then choose Add Signal Emitter
- In the Inspector window, click on Create Signal Asset, choose a file name and hit Enter (one less click :p)
- Still in the Inspector, click the Create Reaction button.
Thatâs it! In the Unity Event UI, you can setup what is necessary for the reaction associated with the signal you just created.
Can I create my own markers/signals?
Yes, you can. See this thread: New in 2019.1 - Marker Customization
Iâm finished! It was a long wait, but we hope it was worth it. Enjoy!