/// <summary> /// Detects if the Oculus Integration package is present and updates the project definitions and prefab references. /// </summary> internal static void ConfigureOculusIntegration(bool oculusIntegrationPresent) { // Update the CSC to filter out warnings emitted by the Oculus Integration Package if (oculusIntegrationPresent) { UpdateCSC(); } // Updating the device manager profile to point to the right gameobjects string[] defaultOvrCameraRigPPrefabGuids = AssetDatabase.FindAssets(Path.GetFileNameWithoutExtension("MRTK-Quest_OVRCameraRig.prefab")); string[] defaultLocalAvatarPrefabGuids = AssetDatabase.FindAssets(Path.GetFileNameWithoutExtension("MRTK-Quest_LocalAvatar.prefab")); GameObject defaultOvrCameraRigPrefab = null; GameObject defaultLocalAvatarPrefab = null; if (defaultOvrCameraRigPPrefabGuids.Length > 0) { string ovrCameraRigPrefabPath = AssetDatabase.GUIDToAssetPath(defaultOvrCameraRigPPrefabGuids[0]); defaultOvrCameraRigPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(ovrCameraRigPrefabPath); } if (defaultLocalAvatarPrefabGuids.Length > 0) { string localAvatarPrefabPath = AssetDatabase.GUIDToAssetPath(defaultLocalAvatarPrefabGuids[0]); defaultLocalAvatarPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(localAvatarPrefabPath); } string[] deviceManagerProfileGuids = AssetDatabase.FindAssets("t:OculusXRSDKDeviceManagerProfile"); foreach (string deviceManagerProfileGuid in deviceManagerProfileGuids) { string deviceManagerProfilePath = AssetDatabase.GUIDToAssetPath(deviceManagerProfileGuid); OculusXRSDKDeviceManagerProfile deviceManagerProfile = AssetDatabase.LoadAssetAtPath <OculusXRSDKDeviceManagerProfile>(deviceManagerProfilePath); if (oculusIntegrationPresent) { if (deviceManagerProfile.OVRCameraRigPrefab == null) { deviceManagerProfile.OVRCameraRigPrefab = defaultOvrCameraRigPrefab; } if (deviceManagerProfile.LocalAvatarPrefab == null) { deviceManagerProfile.LocalAvatarPrefab = defaultLocalAvatarPrefab; } } else { deviceManagerProfile.OVRCameraRigPrefab = null; deviceManagerProfile.LocalAvatarPrefab = null; } EditorUtility.SetDirty(deviceManagerProfile); } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
/// <summary> /// Configures the default device manager profile with default prefabs if they are not yet loaded /// </summary> internal static void ConfigureOculusDeviceManagerDefaults() { // Updating the device manager profile to point to the right gameobjects string[] defaultOvrCameraRigPPrefabGuids = AssetDatabase.FindAssets(Path.GetFileNameWithoutExtension("MRTK-Quest_OVRCameraRig.prefab")); string[] defaultLocalAvatarPrefabGuids = AssetDatabase.FindAssets(Path.GetFileNameWithoutExtension("MRTK-Quest_LocalAvatar.prefab")); GameObject defaultOvrCameraRigPrefab = null; GameObject defaultLocalAvatarPrefab = null; if (defaultOvrCameraRigPPrefabGuids.Length > 0) { string ovrCameraRigPrefabPath = AssetDatabase.GUIDToAssetPath(defaultOvrCameraRigPPrefabGuids[0]); defaultOvrCameraRigPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(ovrCameraRigPrefabPath); } if (defaultLocalAvatarPrefabGuids.Length > 0) { string localAvatarPrefabPath = AssetDatabase.GUIDToAssetPath(defaultLocalAvatarPrefabGuids[0]); defaultLocalAvatarPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(localAvatarPrefabPath); } string[] defaultDeviceManagerProfileGuids = AssetDatabase.FindAssets(Path.GetFileNameWithoutExtension("DefaultOculusXRSDKDeviceManagerProfile.asset")); if (defaultDeviceManagerProfileGuids.Length > 0) { string deviceManagerProfilePath = AssetDatabase.GUIDToAssetPath(defaultDeviceManagerProfileGuids[0]); OculusXRSDKDeviceManagerProfile deviceManagerProfile = AssetDatabase.LoadAssetAtPath <OculusXRSDKDeviceManagerProfile>(deviceManagerProfilePath); if (deviceManagerProfile.OVRCameraRigPrefab == null) { deviceManagerProfile.OVRCameraRigPrefab = defaultOvrCameraRigPrefab; } if (deviceManagerProfile.LocalAvatarPrefab == null) { deviceManagerProfile.LocalAvatarPrefab = defaultLocalAvatarPrefab; } EditorUtility.SetDirty(deviceManagerProfile); } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }