A game about forced loneliness, made by TACStudios
1using System; 2using System.Collections.Concurrent; 3using System.Diagnostics; 4using System.Threading; 5 6namespace Unity.VisualScripting 7{ 8 public static class UnityThread 9 { 10 public static Thread thread = Thread.CurrentThread; 11 12 public static Action<Action> editorAsync; 13 14 public static bool allowsAPI => !Serialization.isUnitySerializing && Thread.CurrentThread == thread; 15 16 public static ConcurrentQueue<Action> pendingQueue = new ConcurrentQueue<Action>(); 17 18 internal static void RuntimeInitialize() 19 { 20 thread = Thread.CurrentThread; 21 } 22 23 [Conditional("UNITY_EDITOR")] 24 public static void EditorAsync(Action action) 25 { 26 if (editorAsync == null) 27 pendingQueue.Enqueue(action); 28 else 29 editorAsync.Invoke(action); 30 } 31 } 32}