private void FixedUpdate() { if (FixedUpdateScheduler == null) { UpdateScheduler = new UnityTaskScheduler("Update"); } FixedUpdateScheduler = new UnityTaskScheduler("FixedUpdate"); }
private void LateUpdate() { if (LateUpdateScheduler == null) { LateUpdateScheduler = new UnityTaskScheduler("LateUpdate"); } LateUpdateScheduler.Activate(); }
private void Update() { if (UpdateScheduler == null) { UpdateScheduler = new UnityTaskScheduler("Update"); } UpdateScheduler.Activate(); }
private static void Initialize() { MainThreadId = Thread.CurrentThread.ManagedThreadId; UpdateScheduler = new UnityTaskScheduler("Update"); LateUpdateScheduler = new UnityTaskScheduler("LateUpdate"); FixedUpdateScheduler = new UnityTaskScheduler("FixedUpdate"); SynchronizationContext.SetSynchronizationContext(UpdateScheduler.Context); var go = new GameObject("UnityScheduler"); go.hideFlags = HideFlags.HideAndDontSave; go.AddComponent <UnityScheduler>(); }
private void Awake() { if (Instance != null) { throw new NotSupportedException("UnityScheduler already exists."); } Instance = this; MainThreadId = Thread.CurrentThread.ManagedThreadId; DontDestroyOnLoad(gameObject); UpdateScheduler = new UnityTaskScheduler("Update"); LateUpdateScheduler = new UnityTaskScheduler("LateUpdate"); FixedUpdateScheduler = new UnityTaskScheduler("FixedUpdate"); SynchronizationContext.SetSynchronizationContext(UpdateScheduler.Context); }
private IEnumerator Start() { UnityTaskScheduler.Initialize(); var task = Task.Run(() => print("First action.")) .ContinueWith(t => print("wait for click")) .ContinueWith(WaitForClick()) // <- IEnumerator .ContinueWith(new WaitForSeconds(1)) .ContinueWith(t => { print("Second action."); }) .ContinueWith(new WaitForSeconds(1)) .ContinueWith(t => { print("Third action."); }); yield return(task); print("All done!"); }
public static void InitializeInEditor() { MainThreadId = Thread.CurrentThread.ManagedThreadId; EditorUpdateScheduler = new UnityTaskScheduler("EditorUpdate"); SynchronizationContext.SetSynchronizationContext(EditorUpdateScheduler.Context); }