Created
July 27, 2015 08:01
-
-
Save noisecrime/083d8234b93673606b2e to your computer and use it in GitHub Desktop.
WaitForSeconds replacement - avoid garbage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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