Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

37 wiersze
747 B

  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. public class StaticCoroutine : MonoBehaviour
  5. {
  6. public static void Start(IEnumerator routine)
  7. {
  8. GameObject gameObject = new GameObject();
  9. gameObject.hideFlags = HideFlags.HideAndDontSave;
  10. UnityEngine.Object.DontDestroyOnLoad(gameObject);
  11. gameObject.AddComponent<StaticCoroutine>().Init(routine);
  12. }
  13. private void Init(IEnumerator routine)
  14. {
  15. base.StartCoroutine(this.Execute(routine));
  16. }
  17. private IEnumerator Execute(IEnumerator routine)
  18. {
  19. try
  20. {
  21. while (routine.MoveNext())
  22. {
  23. object obj = routine.Current;
  24. yield return obj;
  25. }
  26. }
  27. finally
  28. {
  29. UnityEngine.Object.Destroy(base.gameObject);
  30. }
  31. yield break;
  32. }
  33. }