đTimeflow Controller
A script to control Timeflow playback at runtime
Last updated
A script to control Timeflow playback at runtime
Last updated
This component may be used to start and stop playback, queue specific markers, or play custom regions in time. Use the Timeflow Controller for cutscenes or to play animations interactively.
To add a new Timeflow Controller, first select the Timeflow instance in the scene that you wish to control, and then select from the main menu:
Tools/Timeflow/Add/Timeflow Controller
The Timeflow Controller is a relatively simple script to provide a general API for working with Timeflow, however it is not comprehensive and much more is possible with custom scripts if needed. This controller is meant to provide basic functionality. If you are a developer with specific needs, you may choose to extend this script or create your own.
Designates the Timeflow instance being controlled. Any other Timeflow instances in the scene will not be affected by this controller, unless they are children of the target Timeflow.
This determines whether the Work Area is used in Timeflow to constrain playback to a specific region in time. In most cases, the Work Area is desired to set the start and end time for the current marker being played, though it may be turned off to continue to play the timeline until the end, or until interrupted by another event.
This sets the default play mode when the Play() method is called.
The play mode can also be set dynamically by script or event by calling one of the SetPlayMode methods.
This specifies the duration in seconds to lead out of the current work area region when Skip() is invoked. If for example the current work area ends at 10 seconds and the skip duration is set to 2, invoking Skip() will fast forward to 8 seconds and play through to the end at 10.
Use the Skip Duration to provide a smooth outro transition. Otherwise, if the value is set to 0, playback will stop abruptly (cut) when Skip() is invoked. Note also that you can set the Skip Duration by script or event if needed.
Queues Timeflow to play on scene start at the designated marker by index value. Each marker in Timeflow has a unique index (integer value). Typically, 1 is the first index in the scene unless it has been changed.
Note that index values may change if the Re-Index command is used in the Timeflow Markers inspector.
Sets the play mode initially upon scene start.
Determines how playback behaves, with one of the following settings.
Timeflow does not play and remains paused. Use this mode to stop Timeflow completely.
Plays through the designated time region once. When it reaches the end of the current area, playback stops.
One Shot mode is typically used for cutscenes to play a specific section of the timeline just once and then stop.
Plays the current work area (or full timeline) repeating indefinitely.
Use Looped mode to create living holds or sections of time that play repeatedly until interrupted by the user or some other event.
This mode continues to play even when the end of the work area is reached. However, playback will stop when it reaches the end of the timeline.
The following events can be configured in the editor to perform additional actions. These can be used to setup game logic in the editor without additional scripting. For more information, see the Unity Events documentation.
Unity Events are also helpful for decoupling logical components in a game. For programmers, one helpful tip is that you may use ScriptableObjects to receive and pass events and data between scenes without directly referencing game objects in the scene.
This event is called once when the Timeflow Controller initially starts. This event is invoked during Start(), after the above startup play mode has been executed.
This event is invoked each time any Play method is called on the Timeflow Controller.
Use On Play to setup additional logic when playing a section of time. For example, this can be used when playing cutscenes to disable player input and display UI elements.
This event is invoked once playback stops or reaches the end of the current time section.
Use this event to return control back to the player after a cutscene and to hide any other elements displayed during playback.
This event is invoke when Skip() is called, either by script or by an event.
Use this event to perform additional logic when playback is skipped by the user or interrupted by another event.
The following methods are defined in the Timeflow Controller script and may be called wither by script or events.
Explicitly set the start time of the playback region.
Sets the end time of the current playback region.
Sets the start and end time of the current playback region in one call.
Queue playback starting from the marker with the given index, automatically setting the time region up to the following marker.
Queues playback of a marker region with a specific name, automatically setting the time range up to the next marker after it.
Using marker names is preferred in most cases since it is easier to read.
Be careful to enter marker names precisely. They are case sensitive. If no marker is found matching the specified name, nothing will happen.
Queues playback using a marker reference. This is called internally or by other scripts with a TimeflowMarker object.
Starts playback from a specific time in seconds.
Starts playback from the beginning of the current work area, or the start of the timeline if the work area is off.
Resumes playing from the current time.
Advances time to the end of the current work area. If the Skip Duration is set, the time is advanced to that duration before the end, to allow lead out time.
Stops playback. This is also the same as pausing Timeflow. If Play() is called afterward, it resumes from the current tiem.
Sets the current play mode to One Shot.
The SetPlayMode...() methods can be set by script or an event to prepare a cutscene or other section of time for playback. It's best to call this before Play().
Sets the current play mode to Continuous.
Sets the current play mdoe to Looped.