using System; using UnityEditor; using UnityEditorInternal; using UnityEngine; namespace Unity.Cloud.Collaborate.Utilities { internal static class Threading { /// /// Returns true if the current thread is the main thread, false otherwise. /// public static bool IsMainThread => InternalEditorUtility.CurrentThreadIsMainThread(); /// /// Ensure that the provided action is executed on the UI/main thread. /// /// Action to perform on the UI/main thread. public static void EnsureUiThread(Action action) { if (IsMainThread) { action(); } else { EditorApplication.delayCall += () => action(); } } } }