IEnumerator RunEndOfFrameMicroCoroutine() { this.endOfFrameMicroCoroutine = new MicroCoroutine( () => { if (endOfFrameCountForRefresh > EndOfFrameRefreshCycle) { endOfFrameCountForRefresh = 0; return(true); } else { return(false); } }, ex => unhandledExceptionCallback(ex)); while (true) { yield return(YieldInstructionCache.WaitForEndOfFrame); endOfFrameCountForRefresh++; endOfFrameMicroCoroutine.Run(); } }
IEnumerator RunFixedUpdateMicroCoroutine() { this.fixedUpdateMicroCoroutine = new MicroCoroutine( () => { if (fixedUpdateCountForRefresh > FixedUpdateRefreshCycle) { fixedUpdateCountForRefresh = 0; return(true); } else { return(false); } }, ex => unhandledExceptionCallback(ex)); while (true) { yield return(YieldInstructionCache.WaitForFixedUpdate); fixedUpdateCountForRefresh++; fixedUpdateMicroCoroutine.Run(); } }
IEnumerator RunUpdateMicroCoroutine() { this.updateMicroCoroutine = new MicroCoroutine( () => { if (updateCountForRefresh > UpdateRefreshCycle) { updateCountForRefresh = 0; return(true); } else { return(false); } }, ex => unhandledExceptionCallback(ex)); while (true) { yield return(null); updateCountForRefresh++; updateMicroCoroutine.Run(); } }
IEnumerator RunEndOfFrameMicroCoroutine() { this.endOfFrameMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); while (true) { yield return(YieldInstructionCache.WaitForEndOfFrame); endOfFrameMicroCoroutine.Run(); } }
IEnumerator RunFixedUpdateMicroCoroutine() { this.fixedUpdateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); while (true) { yield return(YieldInstructionCache.WaitForFixedUpdate); fixedUpdateMicroCoroutine.Run(); } }
IEnumerator RunUpdateMicroCoroutine() { this.updateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); while (true) { yield return(null); updateMicroCoroutine.Run(); } }
void Awake() { if (instance == null) { instance = this; mainThreadToken = new object(); initialized = true; #if (NET_4_6) if (UniRxSynchronizationContext.AutoInstall) { SynchronizationContext.SetSynchronizationContext(new UniRxSynchronizationContext()); } #endif updateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); fixedUpdateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); endOfFrameMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); StartCoroutine(RunUpdateMicroCoroutine()); StartCoroutine(RunFixedUpdateMicroCoroutine()); StartCoroutine(RunEndOfFrameMicroCoroutine()); DontDestroyOnLoad(gameObject); } else { if (this != instance) { if (cullingMode == CullingMode.Self) { // Try to destroy this dispatcher if there's already one in the scene. Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Removing myself..."); DestroyDispatcher(this); } else if (cullingMode == CullingMode.All) { Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Cleaning up all excess dispatchers..."); CullAllExcessDispatchers(); } else { Debug.LogWarning("There is already a MainThreadDispatcher in the scene."); } } } }
void Awake() { if (instance == null) { instance = this; mainThreadToken = new object(); initialized = true; updateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); fixedUpdateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); endOfFrameMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); StartCoroutine(RunUpdateMicroCoroutine()); StartCoroutine(RunFixedUpdateMicroCoroutine()); StartCoroutine(RunEndOfFrameMicroCoroutine()); DontDestroyOnLoad(gameObject); } else { if (this == instance) { return; } switch (cullingMode) { case CullingMode.Self: // Try to destroy this dispatcher if there's already one in the scene. Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Removing myself..."); DestroyDispatcher(this); break; case CullingMode.All: Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Cleaning up all excess dispatchers..."); CullAllExcessDispatchers(); break; default: Debug.LogWarning("There is already a MainThreadDispatcher in the scene."); break; } } }
void Awake() { if (instance == null) { instance = this; mainThreadToken = new object(); initialized = true; updateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); fixedUpdateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); endOfFrameMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); lateUpdateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex)); StartCoroutine(RunUpdateMicroCoroutine()); StartCoroutine(RunFixedUpdateMicroCoroutine()); StartCoroutine(RunEndOfFrameMicroCoroutine()); // Late update microcoroutine run is called in Unity's .LateUpdate() DontDestroyOnLoad(gameObject); } else { if (this != instance) { if (cullingMode == CullingMode.Self) { // Try to destroy this dispatcher if there's already one in the scene. Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Removing myself..."); DestroyDispatcher(this); } else if (cullingMode == CullingMode.All) { Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Cleaning up all excess dispatchers..."); CullAllExcessDispatchers(); } else { Debug.LogWarning("There is already a MainThreadDispatcher in the scene."); } } } }
private void Awake() { if (instance == null) { instance = this; mainThreadToken = new object(); initialized = true; updateMicroCoroutine = new MicroCoroutine(delegate(Exception ex) { unhandledExceptionCallback(ex); }); fixedUpdateMicroCoroutine = new MicroCoroutine(delegate(Exception ex) { unhandledExceptionCallback(ex); }); endOfFrameMicroCoroutine = new MicroCoroutine(delegate(Exception ex) { unhandledExceptionCallback(ex); }); StartCoroutine(RunUpdateMicroCoroutine()); StartCoroutine(RunFixedUpdateMicroCoroutine()); StartCoroutine(RunEndOfFrameMicroCoroutine()); UnityEngine.Object.DontDestroyOnLoad(base.gameObject); } else if (this != instance) { if (cullingMode == CullingMode.Self) { UnityEngine.Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Removing myself..."); DestroyDispatcher(this); } else if (cullingMode == CullingMode.All) { UnityEngine.Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Cleaning up all excess dispatchers..."); CullAllExcessDispatchers(); } else { UnityEngine.Debug.LogWarning("There is already a MainThreadDispatcher in the scene."); } } }