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 839B

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