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.

UnitySumbmissionNodeScheduler.cs 924B

7 years ago
7 years ago
7 years ago
7 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #if UNITY_5 || UNITY_5_3_OR_NEWER
  2. using System;
  3. using System.Collections;
  4. using UnityEngine;
  5. namespace Svelto.ECS.NodeSchedulers
  6. {
  7. public class UnitySumbmissionNodeScheduler : NodeSubmissionScheduler
  8. {
  9. public UnitySumbmissionNodeScheduler()
  10. {
  11. GameObject go = new GameObject("ECSScheduler");
  12. _scheduler = go.AddComponent<Scheduler>();
  13. }
  14. public override void Schedule(Action submitNodes)
  15. {
  16. _scheduler.OnTick += submitNodes;
  17. }
  18. class Scheduler : MonoBehaviour
  19. {
  20. IEnumerator Start()
  21. {
  22. while (true)
  23. {
  24. yield return _wait;
  25. OnTick();
  26. }
  27. }
  28. internal Action OnTick;
  29. WaitForEndOfFrame _wait = new WaitForEndOfFrame();
  30. }
  31. Scheduler _scheduler;
  32. }
  33. }
  34. #endif