Example #1
0
 /// <summary>
 /// Executes <see cref="MonoBehaviour.StartCoroutine(IEnumerator)"/> on the specified <paramref name="routine"/>.
 /// </summary>
 /// <param name="routine">The coroutine to start.</param>
 /// <returns>The instance of the <see cref="Coroutine"/> that was created while starting the routine.</returns>
 public static Coroutine Do(IEnumerator routine)
 {
     if (instance == null)
     {
         GameObject obj = new GameObject("Static Coroutine Object")
         {
             hideFlags = HideFlags.HideInHierarchy
         };
         instance = obj.AddComponent <StaticCoroutine>();
         DontDestroyOnLoad(obj);
     }
     return(instance.StartCoroutine(routine));
 }