Mirror of Svelto.ECS because we're a fan of it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
716B

  1. #if UNITY_5 || UNITY_5_3_OR_NEWER
  2. using System.Collections;
  3. using UnityEngine;
  4. namespace Svelto.ECS.Schedulers.Unity
  5. {
  6. class MonoScheduler : MonoBehaviour
  7. {
  8. public MonoScheduler()
  9. {
  10. _coroutine = Coroutine();
  11. }
  12. void Update()
  13. {
  14. _coroutine.MoveNext();
  15. }
  16. IEnumerator Coroutine()
  17. {
  18. while (true)
  19. {
  20. yield return _wait;
  21. onTick();
  22. }
  23. }
  24. readonly WaitForEndOfFrame _wait = new WaitForEndOfFrame();
  25. readonly IEnumerator _coroutine;
  26. internal System.Action onTick;
  27. }
  28. }
  29. #endif