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