@@ -41,13 +41,14 @@ public override bool support
4141 }
4242 }
4343
44+ private static GUIContent s_title = new GUIContent ( "OpenXR Desktop (Experimental)" ) ;
4445 public override void OnPreferenceGUI ( )
4546 {
46- const string title = "OpenXR Desktop (Experimental)" ;
47+ const float toggleWidth = 263f ;
4748 if ( canSupport )
4849 {
4950 var wasSupported = support ;
50- var shouldSupport = Foldouter . ShowFoldoutBlankWithEnabledToggle ( new GUIContent ( title ) , support ) ;
51+ var shouldSupport = Foldouter . ShowFoldoutBlankWithEnabledToggle ( s_title , support ) ;
5152 if ( wasSupported != shouldSupport )
5253 {
5354 support = shouldSupport ;
@@ -58,18 +59,35 @@ public override void OnPreferenceGUI()
5859 GUILayout . BeginHorizontal ( ) ;
5960 Foldouter . ShowFoldoutBlank ( ) ;
6061
62+ #if ! UNITY_2020_2_OR_NEWER
63+ GUI . enabled = false ;
64+ ShowToggle ( new GUIContent ( s_title . text , "Unity 2020.2 or later version required." ) , false , GUILayout . Width ( toggleWidth ) ) ;
65+ GUI . enabled = true ;
66+ #else
6167 if ( activeBuildTargetGroup != requirdPlatform )
6268 {
6369 GUI . enabled = false ;
64- ShowToggle ( new GUIContent ( title , requirdPlatform + " platform required." ) , false , GUILayout . Width ( 230f ) ) ;
70+ ShowToggle ( new GUIContent ( s_title . text , requirdPlatform + " platform required." ) , false , GUILayout . Width ( toggleWidth ) ) ;
6571 GUI . enabled = true ;
6672 GUILayout . FlexibleSpace ( ) ;
6773 ShowSwitchPlatformButton ( requirdPlatform , BuildTarget . StandaloneWindows64 ) ;
6874 }
75+ else if ( ! PackageManagerHelper . IsPackageInList ( OPENXR_PLUGIN_PACKAGE_NAME ) )
76+ {
77+ GUI . enabled = false ;
78+ ShowToggle ( s_title , false , GUILayout . Width ( toggleWidth ) ) ;
79+ GUI . enabled = true ;
80+ GUILayout . FlexibleSpace ( ) ;
81+
82+ if ( GUILayout . Button ( new GUIContent ( "Add OpenXR Plugin" , "Add " + OPENXR_PLUGIN_PACKAGE_NAME + " to Package Manager" ) , GUILayout . ExpandWidth ( false ) ) )
83+ {
84+ PackageManagerHelper . AddToPackageList ( OPENXR_PLUGIN_PACKAGE_NAME ) ;
85+ }
86+ }
6987 else if ( ! XRPluginManagementUtils . IsXRLoaderEnabled ( OPENXR_PLUGIN_LOADER_NAME , requirdPlatform ) )
7088 {
7189 GUI . enabled = false ;
72- ShowToggle ( new GUIContent ( title ) , false , GUILayout . Width ( 230f ) ) ;
90+ ShowToggle ( s_title , false , GUILayout . Width ( toggleWidth ) ) ;
7391 GUI . enabled = true ;
7492 GUILayout . FlexibleSpace ( ) ;
7593
@@ -81,7 +99,7 @@ public override void OnPreferenceGUI()
8199 }
82100 }
83101 }
84-
102+ #endif
85103 GUILayout . EndHorizontal ( ) ;
86104 }
87105 }
0 commit comments