Skip to content

Instantly share code, notes, and snippets.

@noisecrime
Created July 27, 2015 08:01
Show Gist options
  • Save noisecrime/083d8234b93673606b2e to your computer and use it in GitHub Desktop.
Save noisecrime/083d8234b93673606b2e to your computer and use it in GitHub Desktop.
WaitForSeconds replacement - avoid garbage
static public IEnumerator Wait( float duration )
{
while( duration > 0 )
{
duration -= Time.deltaTime;
yield return null; // 'yield return 0;' generates garbage from C# boxing, so always use 'yield return null;' instead
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment