Timeflow Animation System is a sequencing tool available on the Unity Asset Store:
https://assetstore.unity.com/packages/tools/animation/timeflow-animation-system-247895
The following custom Action can be used to control playback of a Timeflow sequence, as well as optionally wait for it to complete.
To use it, copy/paste the code below into a C# file named ActionTimeflow.cs, and install it using the guide covered in this tutorial.
using System.Collections.Generic;
using AxonGenesis;
using UnityEditor;
namespace AC
{
public class ActionTimeflow : Action
{
public int constantID = 0;
public int parameterID = -1;
public TimeflowController timeflowController;
protected TimeflowController runtimeTimeflowController;
public enum Method { Play, PlayFromStart, PlayFromTime, PlayFromMarkerIndex, PlayFromMarker, Stop };
public Method method = Method.Play;
public string markerName;
public float startTime;
public int markerIndex;
public override ActionCategory Category { get { return ActionCategory.ThirdParty; }}
public override string Title { get { return "Timeflow"; }}
public override string Description { get { return "Controls playback of a Timeflow."; }}
public override void AssignValues (List<ActionParameter> parameters)
{
runtimeTimeflowController = AssignFile <TimeflowController> (parameters, parameterID, constantID, timeflowController);
}
public override float Run ()
{
if (runtimeTimeflowController == null || runtimeTimeflowController.Timeflow == null)
{
LogWarning ("Cannot play Timeflow - no valid Timeflow Controller assigned!");
return 0f;
}
if (!isRunning)
{
switch (method)
{
case Method.Play:
runtimeTimeflowController.Play ();
break;
case Method.PlayFromStart:
runtimeTimeflowController.PlayFromStart ();
break;
case Method.PlayFromTime:
runtimeTimeflowController.PlayFromTime (startTime);
break;
case Method.PlayFromMarker:
runtimeTimeflowController.PlayFromMarker (markerName);
break;
case Method.PlayFromMarkerIndex:
runtimeTimeflowController.PlayFromMarkerIndex (markerIndex);
break;
case Method.Stop:
runtimeTimeflowController.Stop ();
break;
default:
break;
}
if (method != Method.Stop && willWait)
{
isRunning = true;
return defaultPauseTime;
}
}
else
{
if (timeflowController.Timeflow.IsPlaying)
{
return defaultPauseTime;
}
isRunning = false;
}
return 0f;
}
#if UNITY_EDITOR
public override void ShowGUI (List<ActionParameter> parameters)
{
ComponentField ("Timeflow controller:", ref timeflowController, ref constantID, parameters, ref parameterID);
method = (Method) EditorGUILayout.EnumPopup ("Method:", method);
switch (method)
{
default:
break;
case Method.PlayFromTime:
startTime = EditorGUILayout.FloatField ("Start time:", startTime);
break;
case Method.PlayFromMarkerIndex:
markerIndex = EditorGUILayout.IntField ("Marker index:", markerIndex);
break;
case Method.PlayFromMarker:
markerName = EditorGUILayout.TextField ("Marker name:", markerName);
break;
}
if (method != Method.Stop)
{
willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait);
}
}
#endif
}
}