/// <summary> /// Default draw line with Debug.DrawLine. Works in subthreads /// </summary> public static void DefDrawLine(Vector3 start, Vector3 end, Color color, float duration) { if (!MainThreadInvoker.CheckForMainThread()) { MainThreadInvoker.InvokeAction(() => Debug.DrawLine(start, end, color, duration)); } else { Debug.DrawLine(start, end, color, duration); } }
/// <summary> /// Send log message with logMethod /// </summary> /// <param name="logMethod">Debug.Log, Debug.LogWarning, etc.</param> /// <param name="objects">ToString objects (+arrays)</param> /// <param name="sep">Separator</param> /// <param name="format">Format string</param> /// <param name="threadName">Current thread name</param> public static void LogMethod(Action <string> logMethod, object[] objects, string sep, string format, string worker, string threadName) { if (!MainThreadInvoker.CheckForMainThread()) { MainThreadInvoker.InvokeAction(() => LogMethod(logMethod, objects, sep, format, worker, threadName)); return; } if (string.IsNullOrEmpty(threadName)) { threadName = "Main thread"; } string text = GetText(objects, sep); string formattedText = Formatter(text, format, worker, threadName); logMethod(formattedText); }