NativeAppInfo.cs 944 B

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