Awaitable Tweens and Sequences
Tweens and Sequences can be made into Awaitable
methods. The main restriction is that one cannot have Awaitable tweens with infinite loop counts (i.e., <= 0).
Examples of how to use this feature are part of the TweenerFlex and TweenSpecSequence tiles.
Here's a bit of the code for the TweenerFlex tile:
private async Awaitable WaitForCompletion(long tId)
{
if (m_LoopCount < 0)
{
//NOTE: The TweenAsAwaitable call below will fail if the loop count is < 0
Debug.Log("infinite loop count tweens should not be awaited!");
return;
}
var at = TweenerService.TweenAsAwaitable(tId);
if (at == null)
return;
//The elapsed time calculation is obviously not required.
var now = Time.time;
var s = TweenerService.GetTweenInfo(tId);
await at;
Debug.Log($"Awaitable tween complete, ET: {Time.time-now}. Id = {tId}\n{s}");
}
It's pretty simple to use Awaitable tweens. Awaitable sequences are very similar, but you'll note that the Awaitable method is cancelled if the Sequence can't launch for some reason.
TpLibTasks has this Handy Helper method for Awaitables:
public static async Awaitable WhenAll(List<Awaitable> awaitables)