2using System.Collections.Generic;
9public class Loom : MonoBehaviour
11 private static Loom _current;
17 if (_current ==
null && Application.isPlaying)
19 var g = GameObject.Find(
"Loom");
20 if (g ==
null) g =
new GameObject(
"Loom");
22 _current = g.GetComponent<
Loom>() ?? g.AddComponent<
Loom>();
31 if (_current !=
null && _current !=
this)
37 private readonly List<Action> _actions =
new List<Action>();
46 private readonly List<DelayedQueueItem> _delayed =
new List<DelayedQueueItem>();
52 if (
Current._delayed.Any(d => d.name == name))
87 var t =
new Thread(RunAction);
92 private static void RunAction(
object action)
98 readonly List<Action> toBeRun =
new List<Action>();
99 readonly List<DelayedQueueItem> toBeDelayed =
new List<DelayedQueueItem>();
106 toBeRun.AddRange(_actions);
110 foreach (var a
in toBeRun)
117 Debug.LogError(
"Queued Exception: " + e);
123 toBeDelayed.AddRange(_delayed);
126 foreach (var delayed
in toBeDelayed.Where(d => d.time <= Time.time))
130 _delayed.Remove(delayed);
139 Debug.LogError(
"Delayed Exception:" + e);
System.Threading.ThreadPriority ThreadPriority
static void QueueOnMainThread(Action action)
static void RunAsync(Action a)
static void QueueOnMainThread(Action action, float time, string name)
static void QueueOnMainThread(Action action, float time)
static void QueueOnMainThread(Action action, string name)