CoroutineManager.cs 902 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. namespace I2.Loc
  5. {
  6. public class CoroutineManager : MonoBehaviour
  7. {
  8. private static CoroutineManager pInstance
  9. {
  10. get
  11. {
  12. if (CoroutineManager.mInstance == null)
  13. {
  14. GameObject gameObject = new GameObject("_Coroutiner");
  15. gameObject.hideFlags = HideFlags.HideAndDontSave;
  16. CoroutineManager.mInstance = gameObject.AddComponent<CoroutineManager>();
  17. if (Application.isPlaying)
  18. {
  19. UnityEngine.Object.DontDestroyOnLoad(gameObject);
  20. }
  21. }
  22. return CoroutineManager.mInstance;
  23. }
  24. }
  25. private void Awake()
  26. {
  27. if (Application.isPlaying)
  28. {
  29. UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
  30. }
  31. }
  32. public static Coroutine Start(IEnumerator coroutine)
  33. {
  34. return CoroutineManager.pInstance.StartCoroutine(coroutine);
  35. }
  36. private static CoroutineManager mInstance;
  37. }
  38. }