Aetheria/Assets/Plugins/UniRx/Scripts/UnityEngineBridge/UniRxSynchronizationContext.cs
Reinier Vens dbc522a224 Weapos Rejiggered
Modified weapon scripts to eliminate specialized projectile behavior - allows charged weapons to have projectiles and modify weapon stats when charged
Added machine gun weapon & VFX
Moved third party code to Plugins folder to improve compile times
2021-01-31 03:52:32 +00:00

57 lines
No EOL
1.5 KiB
C#

#if (ENABLE_MONO_BLEEDING_EDGE_EDITOR || ENABLE_MONO_BLEEDING_EDGE_STANDALONE)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace UniRx
{
public class UniRxSynchronizationContext : SynchronizationContext
{
static bool autoInstall = true;
public static bool AutoInstall { get { return autoInstall; } set { autoInstall = value; } }
public override void Post(SendOrPostCallback d, object state)
{
// If is in mainthread, call direct.
if (MainThreadDispatcher.IsInMainThread)
{
d(state);
}
else
{
MainThreadDispatcher.Post(x =>
{
var pair = (Pair)x;
pair.Callback(pair.State);
}, new Pair(d, state));
}
}
public override void Send(SendOrPostCallback d, object state)
{
MainThreadDispatcher.Send(x =>
{
var pair = (Pair)x;
pair.Callback(pair.State);
}, new Pair(d, state));
}
struct Pair
{
public readonly SendOrPostCallback Callback;
public readonly object State;
public Pair(SendOrPostCallback callback, object state)
{
this.Callback = callback;
this.State = state;
}
}
}
}
#endif