static void Initialize() { unityThreadId = Thread.CurrentThread.ManagedThreadId; UnitySyncContext = SynchronizationContext.Current; BackgroundSyncContext = new SynchronizationContext(); // TODO: confirm this produces desired behaviour updates = new ContinuationProcessorGroup(); lateUpdates = new ContinuationProcessorGroup(); fixedUpdates = new ContinuationProcessorGroup(); Instance = new GameObject("Async Manager") { #if !UnityAsync_Debug hideFlags = HideFlags.HideInHierarchy | HideFlags.NotEditable #endif }.AddComponent <AsyncManager>(); if (!Application.isEditor) // DontDestroyOnLoad can not be called in editor mode { DontDestroyOnLoad(Instance); } }
public void OnCompleted(Action continuation) { this.continuation = continuation; AsyncManager.AddContinuation(this); }