private static void RunOnUnityScheduler(Action action) { if (SynchronizationContext.Current == SyncContextUtility.UnitySynchronizationContext) { action(); } else { AsyncCoroutineRunner.Post(action); } }
private static void RunOnUnityScheduler(Action action) { if (SynchronizationContext.Current == SyncContextUtility.UnitySynchronizationContext) { action(); } else { // Make sure there is a running instance of AsyncCoroutineRunner before calling AsyncCoroutineRunner.Post // If not warn the user. Note we cannot call AsyncCoroutineRunner.Instance here as that getter contains // calls to Unity functions that can only be run on the Unity thread if (!AsyncCoroutineRunner.IsInstanceRunning) { Debug.LogWarning("There is no active AsyncCoroutineRunner when an action is posted. Place a GameObject " + "at the root of the scene and attach the AsyncCoroutineRunner script to make it function properly."); } AsyncCoroutineRunner.Post(action); } }