31 lines
762 B
C#
31 lines
762 B
C#
|
|
using System;
|
||
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Runtime.CompilerServices;
|
||
|
|
using System.Threading;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
namespace UnityAsyncAwaitUtil
|
||
|
|
{
|
||
|
|
public static class SyncContextUtil
|
||
|
|
{
|
||
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||
|
|
static void Install()
|
||
|
|
{
|
||
|
|
UnitySynchronizationContext = SynchronizationContext.Current;
|
||
|
|
UnityThreadId = Thread.CurrentThread.ManagedThreadId;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static int UnityThreadId
|
||
|
|
{
|
||
|
|
get; private set;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static SynchronizationContext UnitySynchronizationContext
|
||
|
|
{
|
||
|
|
get; private set;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|