示例#1
0
        public static void RunOnMainThread(Action action)
        {
            UnityDispatchQueue instance = GetInstance();

            lock (instance.actionsQueue)
            {
                instance.actionsQueue.Enqueue(action);
            }
        }
示例#2
0
        private static UnityDispatchQueue GetInstance()
        {
            if (!_instance)
            {
                _instance = FindObjectOfType <UnityDispatchQueue>();
            }

            if (!_instance)
            {
                GameObject go = new GameObject(nameof(UnityDispatchQueue));
                _instance = go.AddComponent <UnityDispatchQueue>();
                DontDestroyOnLoad(_instance);
            }

            return(_instance);
        }
示例#3
0
 private void OnDestroy()
 {
     _instance = null;
 }