public void OnPreprocessBuild(BuildReport report) { if (!OculusBuildTools.OculusLoaderPresentInSettingsForBuildTarget(report.summary.platformGroup)) { return; } if (report.summary.platformGroup == BuildTargetGroup.Android) { GraphicsDeviceType firstGfxType = PlayerSettings.GetGraphicsAPIs(report.summary.platform)[0]; if (firstGfxType != GraphicsDeviceType.OpenGLES3 && firstGfxType != GraphicsDeviceType.Vulkan && firstGfxType != GraphicsDeviceType.OpenGLES2) { throw new BuildFailedException("OpenGLES2, OpenGLES3, and Vulkan are currently the only graphics APIs compatible with the Oculus XR Plugin on mobile platforms."); } if (PlayerSettings.Android.minSdkVersion < AndroidSdkVersions.AndroidApiLevel23) { throw new BuildFailedException("Android Minimum API Level must be set to 23 or higher for the Oculus XR Plugin."); } } if (report.summary.platform == BuildTarget.StandaloneWindows || report.summary.platform == BuildTarget.StandaloneWindows64) { if (PlayerSettings.GetGraphicsAPIs(report.summary.platform)[0] != GraphicsDeviceType.Direct3D11) { throw new BuildFailedException("D3D11 is currently the only graphics API compatible with the Oculus XR Plugin on desktop platforms. Please change the Graphics API setting in Player Settings."); } } }
public void OnPostGenerateGradleAndroidProject(string path) { if (!OculusBuildTools.OculusLoaderPresentInSettingsForBuildTarget(BuildTargetGroup.Android)) { return; } var manifestPath = path + k_AndroidManifestPath; var manifestDoc = new XmlDocument(); manifestDoc.Load(manifestPath); var sdkVersion = (int)PlayerSettings.Android.minSdkVersion; UpdateOrCreateAttributeInTag(manifestDoc, "/", "manifest", "installLocation", "auto"); var nodePath = "/manifest/application"; UpdateOrCreateNameValueElementsInTag(manifestDoc, nodePath, "meta-data", "name", "com.samsung.android.vr.application.mode", "value", "vr_only"); var settings = OculusBuildTools.GetSettings(); var lowOverheadModeVal = ((settings != null) && settings.LowOverheadMode) ? "true" : "false"; UpdateOrCreateNameValueElementsInTag(manifestDoc, nodePath, "meta-data", "name", "com.unity.xr.oculus.LowOverheadMode", "value", lowOverheadModeVal); nodePath = "/manifest/application"; UpdateOrCreateAttributeInTag(manifestDoc, nodePath, "activity", "screenOrientation", "landscape"); UpdateOrCreateAttributeInTag(manifestDoc, nodePath, "activity", "theme", "@android:style/Theme.Black.NoTitleBar.Fullscreen"); var configChangesValue = "keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode"; configChangesValue = ((sdkVersion >= 24) ? configChangesValue + "|density" : configChangesValue); UpdateOrCreateAttributeInTag(manifestDoc, nodePath, "activity", "configChanges", configChangesValue); if (sdkVersion >= 24) { UpdateOrCreateAttributeInTag(manifestDoc, nodePath, "activity", "resizeableActivity", "false"); } UpdateOrCreateAttributeInTag(manifestDoc, nodePath, "activity", "launchMode", "singleTask"); if (!OculusBuildTools.GetSettings() || OculusBuildTools.GetSettings().V2Signing) { nodePath = "/manifest"; CreateNameValueElementsInTag(manifestDoc, nodePath, "uses-feature", "name", "android.hardware.vr.headtracking", "required", "true", "version", "1"); } if (!OculusBuildTools.GetSettings() || OculusBuildTools.GetSettings().FocusAware) { nodePath = "/manifest/application/activity"; UpdateOrCreateNameValueElementsInTag(manifestDoc, nodePath, "meta-data", "name", "com.oculus.vr.focusaware", "value", "true"); } nodePath = "/manifest/application/activity/intent-filter"; CreateNameValueElementsInTag(manifestDoc, nodePath, "category", "name", "com.oculus.intent.category.VR"); manifestDoc.Save(manifestPath); }
private static void PlaymodeStateChangedEvent(PlayModeStateChange state) { if (state == PlayModeStateChange.EnteredPlayMode) { if (!OculusBuildTools.OculusLoaderPresentInSettingsForBuildTarget(BuildTargetGroup.Standalone)) { return; } if (PlayerSettings.GetGraphicsAPIs(BuildTarget.StandaloneWindows)[0] != GraphicsDeviceType.Direct3D11) { Debug.LogError("D3D11 is currently the only graphics API compatible with the Oculus XR Plugin on desktop platforms. Please change the preferred Graphics API setting in Player Settings."); } } }
public void OnPostGenerateGradleAndroidProject(string path) { if (!OculusBuildTools.OculusLoaderPresentInSettingsForBuildTarget(BuildTargetGroup.Android)) { return; } AddProGuardRule(path); var manifestPath = path + k_AndroidManifestPath; var manifestDoc = new XmlDocument(); manifestDoc.Load(manifestPath); var sdkVersion = (int)PlayerSettings.Android.minSdkVersion; UpdateOrCreateAttributeInTag(manifestDoc, "/", "manifest", "installLocation", "auto"); var nodePath = "/manifest/application"; UpdateOrCreateNameValueElementsInTag(manifestDoc, nodePath, "meta-data", "name", "com.samsung.android.vr.application.mode", "value", "vr_only"); var settings = OculusBuildTools.GetSettings(); var lowOverheadModeVal = ((settings != null) && settings.LowOverheadMode) ? "true" : "false"; UpdateOrCreateNameValueElementsInTag(manifestDoc, nodePath, "meta-data", "name", "com.unity.xr.oculus.LowOverheadMode", "value", lowOverheadModeVal); nodePath = "/manifest/application"; UpdateOrCreateAttributeInTag(manifestDoc, nodePath, "activity", "screenOrientation", "landscape"); UpdateOrCreateAttributeInTag(manifestDoc, nodePath, "activity", "theme", "@android:style/Theme.Black.NoTitleBar.Fullscreen"); var configChangesValue = "keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode"; configChangesValue = ((sdkVersion >= 24) ? configChangesValue + "|density" : configChangesValue); UpdateOrCreateAttributeInTag(manifestDoc, nodePath, "activity", "configChanges", configChangesValue); if (sdkVersion >= 24) { UpdateOrCreateAttributeInTag(manifestDoc, nodePath, "activity", "resizeableActivity", "false"); } UpdateOrCreateAttributeInTag(manifestDoc, nodePath, "activity", "launchMode", "singleTask"); nodePath = "/manifest"; CreateNameValueElementsInTag(manifestDoc, nodePath, "uses-feature", "name", "android.hardware.vr.headtracking", "required", "true", "version", "1"); string supportedDevices = null; if (settings != null) { var deviceList = new List <string>(); if (settings.TargetQuest) { deviceList.Add("quest"); } if (settings.TargetQuest2) { deviceList.Add("quest2"); } if (deviceList.Count > 0) { StringBuilder sb = new StringBuilder(); string delim = ""; foreach (string device in deviceList) { sb.Append(delim); sb.Append(device); delim = "|"; } supportedDevices = sb.ToString(); } else { Debug.LogWarning("No target devices selected in Oculus Android project settings. No devices will be listed as supported in the application Android manifest."); } } else { supportedDevices = "quest|quest2"; } if (supportedDevices != null) { nodePath = "/manifest/application"; UpdateOrCreateNameValueElementsInTag(manifestDoc, nodePath, "meta-data", "name", "com.oculus.supportedDevices", "value", supportedDevices); } nodePath = "/manifest/application/activity"; UpdateOrCreateNameValueElementsInTag(manifestDoc, nodePath, "meta-data", "name", "com.oculus.vr.focusaware", "value", "true"); nodePath = "/manifest/application/activity/intent-filter"; CreateNameValueElementsInTag(manifestDoc, nodePath, "category", "name", "com.oculus.intent.category.VR"); // if the Microphone class is used in a project, the BLUETOOTH permission is automatically added to the manifest // we remove it here since it will cause projects to fail Oculus cert // this shouldn't affect Bluetooth HID devices, which don't need the permission nodePath = "/manifest"; RemoveNameValueElementInTag(manifestDoc, nodePath, "uses-permission", "android:name", "android.permission.BLUETOOTH"); manifestDoc.Save(manifestPath); }