NativeAppInfo.cs 1004 B

12345678910111213141516171819202122232425262728293031323334
  1. #if UNITY_EDITOR
  2. using System;
  3. using System.Runtime.InteropServices;
  4. public static class NativeAppInfo
  5. {
  6. #if UNITY_IOS && !UNITY_EDITOR
  7. private static IntPtr AppRuntimes_GetTestUserID() => NativeApi.AppInfo.AppRuntimes_GetTestUserID();
  8. private static int AppRuntimes_GetEnableUnityLog() => NativeApi.AppInfo.AppRuntimes_GetEnableUnityLog();
  9. private static void AppRuntimes_FreeString(IntPtr value) => NativeApi.AppInfo.AppRuntimes_FreeString(value);
  10. #endif
  11. public static bool GetEnableUnityLog()
  12. {
  13. #if UNITY_IOS && !UNITY_EDITOR
  14. return AppRuntimes_GetEnableUnityLog() != 0;
  15. #else
  16. return false;
  17. #endif
  18. }
  19. public static string GetTestUrl()
  20. {
  21. #if UNITY_IOS && !UNITY_EDITOR
  22. var value = AppRuntimes_GetTestUserID();
  23. if (value == IntPtr.Zero) return string.Empty;
  24. try { return Marshal.PtrToStringAnsi(value) ?? string.Empty; }
  25. finally { AppRuntimes_FreeString(value); }
  26. #else
  27. return string.Empty;
  28. #endif
  29. }
  30. }
  31. #endif