Skip to content

Commit a9b55cf

Browse files
committed
Added WaitForTween custom yield instruction.
1 parent b092ece commit a9b55cf

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88
- Added option to tween using unscaled delta time.
9+
- Added WaitForTween custom yield instruction.
910
- Added JetBrain annotations.
1011
- Replaced exceptions with Debug.Warning.
1112

Runtime/Tween.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,4 +491,37 @@ private sealed class TweenMono : MonoBehaviour
491491

492492
#endregion
493493
}
494+
495+
#region Other types
496+
497+
/// <summary>
498+
/// Yield instruction that waits for a given tween instance to finish.
499+
/// Usage: yield return new WaitForTween(...)
500+
/// </summary>
501+
public sealed class WaitForTween : CustomYieldInstruction
502+
{
503+
#region Fields
504+
505+
[PublicAPI, CanBeNull]
506+
public readonly Tween Tween;
507+
508+
#endregion
509+
510+
#region Constructors
511+
512+
public WaitForTween([CanBeNull] Tween tween)
513+
{
514+
Tween = tween;
515+
}
516+
517+
#endregion
518+
519+
#region Properties
520+
521+
public override bool keepWaiting => Tween?.IsActive ?? false;
522+
523+
#endregion
524+
}
525+
526+
#endregion
494527
}

0 commit comments

Comments
 (0)