Skip to content

Commit e83cb1e

Browse files
committed
Update support option in VIU Settings
Now OpenVR, WMR option no longer supported OpenXR Use OpenXR Desktop support instead
1 parent 4d707aa commit e83cb1e

4 files changed

Lines changed: 39 additions & 40 deletions

File tree

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Editor/VRPlatformSettings/OpenVRSettings.cs

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -387,14 +387,15 @@ public override bool canSupport
387387
{
388388
get
389389
{
390+
if (activeBuildTargetGroup != requirdPlatform) { return false; }
390391
#if UNITY_2019_3_OR_NEWER
391-
return activeBuildTargetGroup == BuildTargetGroup.Standalone && (PackageManagerHelper.IsPackageInList(OPENXR_PLUGIN_PACKAGE_NAME) || PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME) || PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME_OLD));
392+
return PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME) || PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME_OLD);
392393
#elif UNITY_2018_1_OR_NEWER
393-
return activeBuildTargetGroup == BuildTargetGroup.Standalone && ((PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME) || PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME_OLD)) || PackageManagerHelper.IsPackageInList(OPENVR_PACKAGE_NAME));
394+
return PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME) || PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME_OLD) || PackageManagerHelper.IsPackageInList(OPENVR_PACKAGE_NAME);
394395
#elif UNITY_5_5_OR_NEWER
395-
return activeBuildTargetGroup == BuildTargetGroup.Standalone;
396+
return true;
396397
#else
397-
return activeBuildTargetGroup == BuildTargetGroup.Standalone && VRModule.isSteamVRPluginDetected;
398+
return VRModule.isSteamVRPluginDetected;
398399
#endif
399400
}
400401
}
@@ -403,17 +404,15 @@ public override bool support
403404
{
404405
get
405406
{
407+
if (!canSupport) { return false; }
406408
#if UNITY_2019_3_OR_NEWER
407-
bool supportOpenVRXR = (VIUSettings.activateSteamVRModule || VIUSettings.activateUnityXRModule) && XRPluginManagementUtils.IsXRLoaderEnabled(SteamVRModule.OPENVR_XR_LOADER_NAME, requirdPlatform);
408-
bool supportOpenXR = VIUSettings.activateUnityXRModule && XRPluginManagementUtils.IsXRLoaderEnabled(UnityXRModule.OPENXR_LOADER_NAME, requirdPlatform);
409-
410-
return canSupport && (supportOpenVRXR || supportOpenXR);
409+
return (VIUSettings.activateSteamVRModule || VIUSettings.activateUnityXRModule) && XRPluginManagementUtils.IsXRLoaderEnabled(SteamVRModule.OPENVR_XR_LOADER_NAME, requirdPlatform);
411410
#elif UNITY_5_5_OR_NEWER
412-
return canSupport && (VIUSettings.activateSteamVRModule || VIUSettings.activateUnityNativeVRModule) && OpenVRSDK.enabled;
411+
return (VIUSettings.activateSteamVRModule || VIUSettings.activateUnityNativeVRModule) && OpenVRSDK.enabled;
413412
#elif UNITY_5_4_OR_NEWER
414-
return canSupport && VIUSettings.activateSteamVRModule && OpenVRSDK.enabled;
413+
return VIUSettings.activateSteamVRModule && OpenVRSDK.enabled;
415414
#else
416-
return canSupport && VIUSettings.activateSteamVRModule && !virtualRealitySupported;
415+
return VIUSettings.activateSteamVRModule && !virtualRealitySupported;
417416
#endif
418417
}
419418
set
@@ -422,11 +421,7 @@ public override bool support
422421

423422
VIUSettings.activateSteamVRModule = value;
424423
#if UNITY_2019_3_OR_NEWER
425-
if (PackageManagerHelper.IsPackageInList(OPENXR_PLUGIN_PACKAGE_NAME))
426-
{
427-
XRPluginManagementUtils.SetXRLoaderEnabled(UnityXRModule.OPENXR_LOADER_CLASS_NAME, requirdPlatform, value);
428-
}
429-
else if (PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME) || PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME_OLD))
424+
if (PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME) || PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME_OLD))
430425
{
431426
XRPluginManagementUtils.SetXRLoaderEnabled(SteamVRModule.OPENVR_XR_LOADER_CLASS_NAME, requirdPlatform, value);
432427
}
@@ -478,16 +473,7 @@ public override void OnPreferenceGUI()
478473
GUILayout.FlexibleSpace();
479474
ShowSwitchPlatformButton(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows64);
480475
}
481-
#if UNITY_2020_2_OR_NEWER && FALSE // openxr not fully supported yet
482-
else if (!PackageManagerHelper.IsPackageInList(OPENXR_PLUGIN_PACKAGE_NAME))
483-
{
484-
GUI.enabled = false;
485-
ShowToggle(new GUIContent(title, "OpenXR Plugin ackage required."), false, GUILayout.Width(230f));
486-
GUI.enabled = true;
487-
GUILayout.FlexibleSpace();
488-
ShowAddPackageButton("OpenXR Plugin", OPENXR_PLUGIN_PACKAGE_NAME);
489-
}
490-
#elif UNITY_2019_3_OR_NEWER && FALSE // openvr xr plugin on Valve registry is obsolete
476+
#if UNITY_2019_3_OR_NEWER && FALSE // openvr xr plugin on Valve registry is obsolete
491477
else if (!PackageManagerHelper.IsPackageInList(OPENVR_XR_PACKAGE_NAME))
492478
{
493479
GUI.enabled = false;

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Editor/VRPlatformSettings/OpenXRAndroidOculusSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public override bool canSupport
7979
if (PackageManagerHelper.IsPackageInList(WAVE_XR_OPENXR_PACKAGE)) { return false; }
8080
if (PackageManagerHelper.IsPackageInList(OCULUS_XR_PACKAGE_NAME)) { return false; }
8181
if (!PackageManagerHelper.IsPackageInList(OPENXR_PLUGIN_PACKAGE_NAME)) { return false; }
82+
if (!XRPluginManagementUtils.IsXRLoaderEnabled(OPENXR_PLUGIN_LOADER_NAME, requirdPlatform)) { return false; }
8283
return true;
8384
}
8485
}

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Editor/VRPlatformSettings/OpenXRDesktopSettings.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,13 @@ public override bool support
3131
{
3232
if (!canSupport) { return false; }
3333
if (!VIUSettings.activateUnityXRModule) { return false; }
34-
if (!XRPluginManagementUtils.OnlyOneXRLoaderEnabled(OPENXR_PLUGIN_LOADER_NAME, requirdPlatform)) { return false; }
35-
if (!IsOpenXRFeatureGroupEnabled(requirdPlatform, WAVE_XR_OPENXR_FEATURE_ID)) { return false; }
36-
if (IsOpenXRFeatureGroupEnabled(requirdPlatform, OCULUS_QUEST_OPENXR_FEATURE_ID)) { return false; }
34+
if (!XRPluginManagementUtils.IsXRLoaderEnabled(OPENXR_PLUGIN_LOADER_NAME, requirdPlatform)) { return false; }
3735
return true;
3836
}
3937
set
4038
{
4139
if (value) { VIUSettings.activateUnityXRModule = true; }
42-
if (value) { XRPluginManagementUtils.SetXRLoaderEnabled(OPENXR_PLUGIN_LOADER_NAME, requirdPlatform, true); }
43-
SetOpenXRFeatureGroupEnable(requirdPlatform, WAVE_XR_OPENXR_FEATURE_ID, value);
44-
SetOpenXRFeatureGroupEnable(requirdPlatform, OCULUS_QUEST_OPENXR_FEATURE_ID, !value);
40+
XRPluginManagementUtils.SetXRLoaderEnabled(OPENXR_PLUGIN_LOADER_TYPE, requirdPlatform, value);
4541
}
4642
}
4743

@@ -50,7 +46,12 @@ public override void OnPreferenceGUI()
5046
const string title = "OpenXR Desktop (Experimental)";
5147
if (canSupport)
5248
{
53-
support = Foldouter.ShowFoldoutBlankWithEnabledToggle(new GUIContent(title), support);
49+
var wasSupported = support;
50+
var shouldSupport = Foldouter.ShowFoldoutBlankWithEnabledToggle(new GUIContent(title), support);
51+
if (wasSupported != shouldSupport)
52+
{
53+
support = shouldSupport;
54+
}
5455
}
5556
else
5657
{
@@ -65,6 +66,21 @@ public override void OnPreferenceGUI()
6566
GUILayout.FlexibleSpace();
6667
ShowSwitchPlatformButton(requirdPlatform, BuildTarget.StandaloneWindows64);
6768
}
69+
else if (!XRPluginManagementUtils.IsXRLoaderEnabled(OPENXR_PLUGIN_LOADER_NAME, requirdPlatform))
70+
{
71+
GUI.enabled = false;
72+
ShowToggle(new GUIContent(title), false, GUILayout.Width(230f));
73+
GUI.enabled = true;
74+
GUILayout.FlexibleSpace();
75+
76+
if (GUILayout.Button(new GUIContent("Enable OpenXR Loader", "Enable OpenXR Loader in XR Plug-in Management"), GUILayout.ExpandWidth(false)))
77+
{
78+
if (!ShowXRPluginManagementSection())
79+
{
80+
Debug.LogError("Fail opening XR Plug-in Management page, please enable OpenXR Loader manually.");
81+
}
82+
}
83+
}
6884

6985
GUILayout.EndHorizontal();
7086
}

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Editor/VRPlatformSettings/WindowsMRSettings.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public override bool canSupport
6464
get
6565
{
6666
#if UNITY_2019_3_OR_NEWER
67-
return activeBuildTargetGroup == BuildTargetGroup.Standalone && (PackageManagerHelper.IsPackageInList(WINDOWSMR_XR_PACKAGE_NAME) || PackageManagerHelper.IsPackageInList(OPENXR_PLUGIN_PACKAGE_NAME));
67+
return activeBuildTargetGroup == BuildTargetGroup.Standalone && PackageManagerHelper.IsPackageInList(WINDOWSMR_XR_PACKAGE_NAME);
6868
#elif UNITY_2018_2_OR_NEWER
6969
return activeBuildTargetGroup == BuildTargetGroup.Standalone && PackageManagerHelper.IsPackageInList(WINDOWSMR_PACKAGE_NAME);
7070
#else
@@ -78,7 +78,7 @@ public override bool support
7878
get
7979
{
8080
#if UNITY_2019_3_OR_NEWER
81-
return canSupport && VIUSettings.activateUnityXRModule && (XRPluginManagementUtils.IsXRLoaderEnabled(UnityXRModule.OPENXR_LOADER_NAME, requirdPlatform) || XRPluginManagementUtils.IsXRLoaderEnabled(WINDOWSMR_XR_LOADER_NAME, requirdPlatform));
81+
return canSupport && VIUSettings.activateUnityXRModule && XRPluginManagementUtils.IsXRLoaderEnabled(WINDOWSMR_XR_LOADER_NAME, requirdPlatform);
8282
#elif UNITY_2018_2_OR_NEWER
8383
return canSupport && VIUSettings.activateUnityNativeVRModule && WindowsMRSDK.enabled;
8484
#else
@@ -89,11 +89,7 @@ public override bool support
8989
{
9090
if (support == value) { return; }
9191
#if UNITY_2019_3_OR_NEWER
92-
if (PackageManagerHelper.IsPackageInList(OPENXR_PLUGIN_PACKAGE_NAME))
93-
{
94-
XRPluginManagementUtils.SetXRLoaderEnabled(UnityXRModule.OPENXR_LOADER_CLASS_NAME, requirdPlatform, value);
95-
}
96-
else if (PackageManagerHelper.IsPackageInList(WINDOWSMR_PACKAGE_NAME))
92+
if (PackageManagerHelper.IsPackageInList(WINDOWSMR_PACKAGE_NAME))
9793
{
9894
XRPluginManagementUtils.SetXRLoaderEnabled(WINDOWSMR_XR_LOADER_CLASS_NAME, requirdPlatform, value);
9995
}

0 commit comments

Comments
 (0)