add IsUnity property
diff --git a/src/csharp/Grpc.Core/Internal/PlatformApis.cs b/src/csharp/Grpc.Core/Internal/PlatformApis.cs
index 6bb4242..9456b30 100644
--- a/src/csharp/Grpc.Core/Internal/PlatformApis.cs
+++ b/src/csharp/Grpc.Core/Internal/PlatformApis.cs
@@ -36,6 +36,7 @@
static readonly bool isWindows;
static readonly bool isMono;
static readonly bool isNetCore;
+ static readonly bool isUnity;
static PlatformApis()
{
@@ -54,6 +55,7 @@
isNetCore = false;
#endif
isMono = Type.GetType("Mono.Runtime") != null;
+ isUnity = Type.GetType("UnityEngine.Application, UnityEngine") != null;
}
public static bool IsLinux
@@ -77,6 +79,14 @@
}
/// <summary>
+ /// true if running on Unity platform.
+ /// </summary>
+ public static bool IsUnity
+ {
+ get { return isUnity; }
+ }
+
+ /// <summary>
/// true if running on .NET Core (CoreCLR), false otherwise.
/// </summary>
public static bool IsNetCore