Last active
December 28, 2022 23:32
-
-
Save andrew-raphael-lukasik/340096057c054ca8971ba9f2e83ba3cc to your computer and use it in GitHub Desktop.
WaitForSeconds cached means less memory allocations because of coroutines
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
//Usage example: | |
//yield return Wait.t2s5;//waits 2.5 seconds | |
using UnityEngine; | |
public class Wait | |
{ | |
public readonly static object frame = null; | |
public readonly static WaitForEndOfFrame endOfFrame = new WaitForEndOfFrame(); | |
public readonly static WaitForFixedUpdate fixedUpdate = new WaitForFixedUpdate(); | |
public static readonly WaitForSecondsRealtime rt0s1 = new WaitForSecondsRealtime( 0.1f ); | |
public static readonly WaitForSecondsRealtime rt0s25 = new WaitForSecondsRealtime( 0.25f ); | |
public static readonly WaitForSecondsRealtime rt1s = new WaitForSecondsRealtime( 1f ); | |
public static readonly WaitForSecondsRealtime rt2s = new WaitForSecondsRealtime( 2f ); | |
public static readonly WaitForSeconds t0s01 = new WaitForSeconds( 0.01f ); | |
public static readonly WaitForSeconds t0s02 = new WaitForSeconds( 0.02f ); | |
public static readonly WaitForSeconds t0s05 = new WaitForSeconds( 0.05f ); | |
public static readonly WaitForSeconds t0s1 = new WaitForSeconds( 0.1f ); | |
public static readonly WaitForSeconds t0s2 = new WaitForSeconds( 0.2f ); | |
public static readonly WaitForSeconds t0s25 = new WaitForSeconds( 0.25f ); | |
public static readonly WaitForSeconds t0s3 = new WaitForSeconds( 0.3f ); | |
public static readonly WaitForSeconds t0s4 = new WaitForSeconds( 0.4f ); | |
public static readonly WaitForSeconds t0s5 = new WaitForSeconds( 0.5f ); | |
public static readonly WaitForSeconds t0s75 = new WaitForSeconds( 0.75f ); | |
public static readonly WaitForSeconds t1s = new WaitForSeconds( 1f ); | |
public static readonly WaitForSeconds t1s5 = new WaitForSeconds( 1.5f ); | |
public static readonly WaitForSeconds t2s = new WaitForSeconds( 2f ); | |
public static readonly WaitForSeconds t2s5 = new WaitForSeconds( 2.5f ); | |
public static readonly WaitForSeconds t3s = new WaitForSeconds( 3f ); | |
public static readonly WaitForSeconds t3s321 = new WaitForSeconds( 3.321f ); | |
public static readonly WaitForSeconds t4s = new WaitForSeconds( 4f ); | |
public static readonly WaitForSeconds t4s5 = new WaitForSeconds( 4.5f ); | |
public static readonly WaitForSeconds t5s = new WaitForSeconds( 5f ); | |
public static readonly WaitForSeconds t6s = new WaitForSeconds( 6f ); | |
public static readonly WaitForSeconds t7s = new WaitForSeconds( 7f ); | |
public static readonly WaitForSeconds t8s = new WaitForSeconds( 8f ); | |
public static readonly WaitForSeconds t8s5 = new WaitForSeconds( 8.5f ); | |
public static readonly WaitForSeconds t9s = new WaitForSeconds( 9f ); | |
public static readonly WaitForSeconds t10s = new WaitForSeconds( 10f ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment