Firstborn/Library/PackageCache/com.unity.collab-proxy@2.0.3/Editor/PlasticSCM/UI/GUIActionRunner.cs
Schaken-Mods 9092858a58 updated to the latest editor
I updated everything to the latest Unity Editor. Also realized I had the wrong shaders on my hairs, those are fixed and the hairs look MUCH better!
2023-05-07 17:43:11 -05:00

50 lines
1.3 KiB
C#

using System;
using System.Threading;
using Codice.LogWrapper;
namespace Unity.PlasticSCM.Editor.UI
{
internal static class GUIActionRunner
{
internal delegate void ActionDelegate();
internal static void RunGUIAction(ActionDelegate action)
{
if (EditorDispatcher.IsOnMainThread)
{
action();
return;
}
lock (mLock)
{
ManualResetEvent syncEvent = new ManualResetEvent(false);
EditorDispatcher.Dispatch(delegate {
try
{
action();
}
catch (Exception e)
{
mLog.ErrorFormat("GUI action failed: {0}", e.Message);
mLog.DebugFormat("Stack trace:{0}{1}", Environment.NewLine, e.StackTrace);
throw;
}
finally
{
syncEvent.Set();
}
});
syncEvent.WaitOne();
}
}
static object mLock = new object();
static readonly ILog mLog = LogManager.GetLogger("GUIActionRunner");
}
}