A collection of practical, reusable custom yield instructions for Unity coroutines — designed to make coroutines more readable, expressive, and powerful than Unity’s built-in WaitForSeconds and WaitUntil.
These yields cover real-world gameplay, UI, animation, and audio workflows you hit every day in Unity projects.
Unity coroutines are great — until they aren’t.
Typical problems:
- Repetitive
whileloops and polling logic - Hard-to-read timing and state checks
- One-off coroutine code that isn’t reusable
- Mixing gameplay logic with low-level timing details
This library solves that by providing clean, intention-revealing yield instructions you can reuse across projects.
- 📖 Highly readable coroutines
- 🔁 Reusable, composable yield instructions
- 🎮 Designed for real gameplay, UI, and audio needs
- 🧠 Reduces boilerplate and polling loops
- ⏱️ Supports scaled and unscaled time
- 🔌 Drop-in utility — no framework lock-in
- Wait for a specific number of frames
- Wait for scaled or unscaled seconds
- Wait until a custom condition is met
- Wait while a condition remains true
- Wait for an animation state to start
- Wait for animation completion
- Wait for blend transitions to finish
- Wait for normalized animation time
- Wait for button click
- Wait for UI element readiness
- Wait for hover / focus
- Wait for cooldown completion
- Wait for audio clip start
- Wait for audio clip end
- Wait for normalized playback time
- Wait for fade-in / fade-out completion
IEnumerator AudioExample()
{
Debug.Log("Start");
audioSource.Play(clip);
yield return new AudioYields.WaitForAudioEnd(audioSource);
Debug.Log("Audio ended");
}IEnumerator AttackSequence()
{
animator.SetTrigger("Attack");
yield return new AnimatorYields.WaitForStateEnter(animator, "Attack");
yield return new AnimatorYields.WaitForStateExit(animator, "Attack");
DealDamage();
}Unity · Unity3D · Coroutines · CustomYieldInstruction ·
Animator · UI · Audio · Game Programming · Async Gameplay ·
Reusable Code · Gameplay Systems