Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5 KiB

  1. namespace Oculus.Platform
  2. {
  3. using UnityEngine;
  4. using System;
  5. using System.Collections;
  6. using System.Runtime.InteropServices;
  7. public sealed class StandalonePlatform
  8. {
  9. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  10. public delegate void UnityLogDelegate(IntPtr tag, IntPtr msg);
  11. public Request<Models.PlatformInitialize> InitializeInEditor()
  12. {
  13. #if UNITY_ANDROID
  14. if (String.IsNullOrEmpty(PlatformSettings.MobileAppID))
  15. {
  16. throw new UnityException("Update your App ID by selecting 'Oculus Platform' -> 'Edit Settings'");
  17. }
  18. var appID = PlatformSettings.MobileAppID;
  19. #else
  20. if (String.IsNullOrEmpty(PlatformSettings.AppID))
  21. {
  22. throw new UnityException("Update your App ID by selecting 'Oculus Platform' -> 'Edit Settings'");
  23. }
  24. var appID = PlatformSettings.AppID;
  25. #endif
  26. if (String.IsNullOrEmpty(StandalonePlatformSettings.OculusPlatformTestUserAccessToken))
  27. {
  28. throw new UnityException("Update your standalone credentials by selecting 'Oculus Platform' -> 'Edit Settings'");
  29. }
  30. var accessToken = StandalonePlatformSettings.OculusPlatformTestUserAccessToken;
  31. return AsyncInitialize(UInt64.Parse(appID), accessToken);
  32. }
  33. public Request<Models.PlatformInitialize> AsyncInitialize(ulong appID, string accessToken)
  34. {
  35. CAPI.ovr_UnityResetTestPlatform();
  36. CAPI.ovr_UnityInitGlobals(IntPtr.Zero);
  37. return new Request<Models.PlatformInitialize>(CAPI.ovr_PlatformInitializeWithAccessToken(appID, accessToken));
  38. }
  39. }
  40. }