예제 #1
0
        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();
            }
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        IEnumerator RunEndOfFrameMicroCoroutine()
        {
            this.endOfFrameMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex));

            while (true)
            {
                yield return(YieldInstructionCache.WaitForEndOfFrame);

                endOfFrameMicroCoroutine.Run();
            }
        }
예제 #5
0
        IEnumerator RunFixedUpdateMicroCoroutine()
        {
            this.fixedUpdateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex));

            while (true)
            {
                yield return(YieldInstructionCache.WaitForFixedUpdate);

                fixedUpdateMicroCoroutine.Run();
            }
        }
예제 #6
0
        IEnumerator RunUpdateMicroCoroutine()
        {
            this.updateMicroCoroutine = new MicroCoroutine(ex => unhandledExceptionCallback(ex));

            while (true)
            {
                yield return(null);

                updateMicroCoroutine.Run();
            }
        }
예제 #7
0
        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.");
                    }
                }
            }
        }
예제 #8
0
        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;
                }
            }
        }
예제 #9
0
        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.");
                    }
                }
            }
        }
예제 #10
0
 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.");
         }
     }
 }