#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2)
#define SupportCustomYieldInstruction
#endif
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using UniRx.InternalUtil;
using UnityEngine;
namespace UniRx
{
public sealed class MainThreadDispatcher : MonoBehaviour
{
public enum CullingMode
{
///
/// Won't remove any MainThreadDispatchers.
///
Disabled,
///
/// Checks if there is an existing MainThreadDispatcher on Awake(). If so, the new dispatcher removes itself.
///
Self,
///
/// Search for excess MainThreadDispatchers and removes them all on Awake().
///
All
}
public static CullingMode cullingMode = CullingMode.Self;
// #if UNITY_EDITOR
//
// // In UnityEditor's EditorMode can't instantiate and work MonoBehaviour.Update.
// // EditorThreadDispatcher use EditorApplication.update instead of MonoBehaviour.Update.
// class EditorThreadDispatcher
// {
// static object gate = new object();
// static EditorThreadDispatcher instance;
//
// public static EditorThreadDispatcher Instance
// {
// get
// {
// // Activate EditorThreadDispatcher is dangerous, completely Lazy.
// lock (gate)
// {
// if (instance == null)
// {
// instance = new EditorThreadDispatcher();
// }
//
// return instance;
// }
// }
// }
//
// ThreadSafeQueueWorker editorQueueWorker = new ThreadSafeQueueWorker();
//
// EditorThreadDispatcher()
// {
// UnityEditor.EditorApplication.update += Update;
// }
//
// public void Enqueue(Action