| 1 | namespace Oculus.Platform |
| 2 | { |
| 3 | using UnityEngine; |
| 4 | using System.Collections; |
| 5 | |
| 6 | #if UNITY_EDITOR |
| 7 | [UnityEditor.InitializeOnLoad] |
| 8 | #endif |
| 9 | public sealed class PlatformSettings : ScriptableObject |
| 10 | { |
| 11 | public static string AppID |
| 12 | { |
| 13 | get { return Instance.ovrAppID; } |
| 14 | set { Instance.ovrAppID = value; } |
| 15 | } |
| 16 | |
| 17 | public static string MobileAppID |
| 18 | { |
| 19 | get { return Instance.ovrMobileAppID; } |
| 20 | set { Instance.ovrMobileAppID = value; } |
| 21 | } |
| 22 | |
| 23 | public static bool UseStandalonePlatform |
| 24 | { |
| 25 | get { return Instance.ovrUseStandalonePlatform; } |
| 26 | set { Instance.ovrUseStandalonePlatform = value; } |
| 27 | } |
| 28 | |
| 29 | public static bool EnableARM64Support |
| 30 | { |
| 31 | get { return Instance.ovrEnableARM64Support; } |
| 32 | set { Instance.ovrEnableARM64Support = value; } |
| 33 | } |
| 34 | |
| 35 | [SerializeField] |
| 36 | private string ovrAppID = ""; |
| 37 | |
| 38 | [SerializeField] |
| 39 | private string ovrMobileAppID = ""; |
| 40 | |
| 41 | #if UNITY_EDITOR_WIN |
| 42 | [SerializeField] |
| 43 | private bool ovrUseStandalonePlatform = false; |
| 44 | #else |
| 45 | [SerializeField] |
| 46 | private bool ovrUseStandalonePlatform = true; |
| 47 | #endif |
| 48 | |
| 49 | [SerializeField] |
| 50 | private bool ovrEnableARM64Support = false; |
| 51 | |
| 52 | private static PlatformSettings instance; |
| 53 | public static PlatformSettings Instance |
| 54 | { |
| 55 | get |
| 56 | { |
| 57 | if (instance == null) |
| 58 | { |
| 59 | instance = Resources.Load<PlatformSettings>("OculusPlatformSettings"); |
| 60 | |
| 61 | // This can happen if the developer never input their App Id into the Unity Editor |
| 62 | // and therefore never created the OculusPlatformSettings.asset file |
| 63 | // Use a dummy object with defaults for the getters so we don't have a null pointer exception |
| 64 | if (instance == null) |
| 65 | { |
| 66 | instance = ScriptableObject.CreateInstance<PlatformSettings>(); |
| 67 | |
| 68 | #if UNITY_EDITOR |
| 69 | // Only in the editor should we save it to disk |
| 70 | string properPath = System.IO.Path.Combine(UnityEngine.Application.dataPath, "Resources"); |
| 71 | if (!System.IO.Directory.Exists(properPath)) |
| 72 | { |
| 73 | UnityEditor.AssetDatabase.CreateFolder("Assets", "Resources"); |
| 74 | } |
| 75 | |
| 76 | string fullPath = System.IO.Path.Combine( |
| 77 | System.IO.Path.Combine("Assets", "Resources"), |
| 78 | "OculusPlatformSettings.asset" |
| 79 | ); |
| 80 | UnityEditor.AssetDatabase.CreateAsset(instance, fullPath); |
| 81 | #endif |
| 82 | } |
| 83 | } |
| 84 | return instance; |
| 85 | } |
| 86 | |
| 87 | set |
| 88 | { |
| 89 | instance = value; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | } |