コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】指定された関数が UniTask の非同期メソッドかどうかを確認する関数

概要

private static bool IsAsynchronousMethod( MethodInfo methodInfo )
{
    return IsUniTask( methodInfo.ReturnType );
}

private static bool IsUniTask( Type type )
{
    return type.IsGenericType
            ? type.GetGenericTypeDefinition() == typeof( UniTask<> )
            : type == typeof( UniTask )
        ;
}