您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

88 行
1.4 KiB

  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. namespace SUISSEngine
  5. {
  6. [Obsolete]
  7. public class UnityCoroutineTask : ICoroutineTask
  8. {
  9. public UnityCoroutineTask(IEnumerator coroutine, MonoBehaviour runner)
  10. {
  11. this._coroutine = coroutine;
  12. this._running = true;
  13. this._isDone = false;
  14. this._unityCoroutine = runner.StartCoroutine(this.InternalRoutine());
  15. }
  16. public void CheckForException()
  17. {
  18. if (this._exception != null)
  19. {
  20. throw this._exception;
  21. }
  22. }
  23. public void Stop()
  24. {
  25. this._running = false;
  26. }
  27. public bool Running
  28. {
  29. get
  30. {
  31. return this._running;
  32. }
  33. }
  34. public bool IsDone
  35. {
  36. get
  37. {
  38. return this._isDone;
  39. }
  40. }
  41. public object YieldUntilDone()
  42. {
  43. return this._unityCoroutine;
  44. }
  45. private IEnumerator InternalRoutine()
  46. {
  47. while (this._running)
  48. {
  49. try
  50. {
  51. if (!this._coroutine.MoveNext())
  52. {
  53. this._running = false;
  54. this._isDone = true;
  55. yield break;
  56. }
  57. }
  58. catch (Exception exception)
  59. {
  60. this._exception = exception;
  61. this._running = false;
  62. this._isDone = true;
  63. yield break;
  64. }
  65. yield return this._coroutine.Current;
  66. }
  67. yield break;
  68. }
  69. private bool _running;
  70. private bool _isDone;
  71. private Exception _exception;
  72. private IEnumerator _coroutine;
  73. private Coroutine _unityCoroutine;
  74. }
  75. }