Waiters is a utility class for Unity that provides optimized and reusable coroutine wait operations.
- Cached
WaitForSecondsandWaitForSecondsRealtimeobjects for improved performance - Efficient memory usage
- Randomized wait times with configurable cache precision
- Manual cache clearing when cached wait intervals are no longer needed
// Wait for a specified number of seconds
yield return Waiters.Wait(1.5f);
// Wait for a specified number of real-time seconds
yield return Waiters.WaitRealtime(2.0f);
// Wait for a random time between min and max seconds
yield return Waiters.WaitRandom(1.0f, 3.0f);
// Wait for a random time using 0.25 second cache buckets
yield return Waiters.WaitRandom(1.0f, 3.0f, 0.25f);
// Clear cached wait intervals
Waiters.ClearCache();
// Wait until the next fixed update
yield return Waiters.FixedUpdate;
// Wait until the end of the frame
yield return Waiters.EndOfFrame;- Copy the
Waiters.csfile into your Unity project's Assets folder. - Use the
Waitersclass in your coroutines for optimized wait operations.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.