Exemplo n.º 1
0
        public static void RunOnMainThread(Action action)
        {
            UnityDispatchQueue instance = GetInstance();

            lock (instance.actionsQueue)
            {
                instance.actionsQueue.Enqueue(action);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 private void OnDestroy()
 {
     _instance = null;
 }