@@ -108,49 +108,53 @@ static void Update()
108108 //window.title = "SteamVR";
109109 }
110110
111- // Switch to native OpenVR support.
112- var updated = false ;
113-
114- if ( ! PlayerSettings . virtualRealitySupported )
111+ if ( SteamVR_Preferences . AutoEnableVR )
115112 {
116- PlayerSettings. virtualRealitySupported = true ;
117- updated = true ;
118- }
113+ // Switch to native OpenVR support.
114+ var updated = false;
115+
116+ if ( ! PlayerSettings . virtualRealitySupported )
117+ {
118+ PlayerSettings . virtualRealitySupported = true ;
119+ updated = true ;
120+ }
119121
120122#if ( UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0 )
121- var devices = UnityEditorInternal. VR. VREditor. GetVREnabledDevices( BuildTargetGroup . Standalone ) ;
123+ var devices = UnityEditorInternal. VR. VREditor. GetVREnabledDevices( BuildTargetGroup . Standalone ) ;
122124#else
123- var devices = UnityEditorInternal. VR. VREditor. GetVREnabledDevicesOnTargetGroup( BuildTargetGroup . Standalone ) ;
125+ var devices = UnityEditorInternal. VR. VREditor. GetVREnabledDevicesOnTargetGroup( BuildTargetGroup . Standalone ) ;
124126#endif
125- var hasOpenVR = false ;
126- foreach ( var device in devices)
127- if ( device . ToLower ( ) == "openvr" )
128- hasOpenVR = true;
127+ var hasOpenVR = false ;
128+ foreach ( var device in devices)
129+ if ( device . ToLower ( ) == "openvr" )
130+ hasOpenVR = true;
129131
130- if ( ! hasOpenVR )
131- {
132- string [ ] newDevices ;
133- if ( updated )
134- {
135- newDevices = new string [ ] { "OpenVR" } ;
136- }
137- else
132+
133+ if ( ! hasOpenVR )
138134 {
139- newDevices = new string [ devices . Length + 1 ] ;
140- for ( int i = 0 ; i < devices . Length ; i++ )
141- newDevices[ i ] = devices [ i ] ;
142- newDevices[ devices . Length ] = "OpenVR" ;
143- updated = true ;
144- }
135+ string [ ] newDevices ;
136+ if ( updated )
137+ {
138+ newDevices = new string [ ] { "OpenVR" } ;
139+ }
140+ else
141+ {
142+ newDevices = new string [ devices . Length + 1 ] ;
143+ for ( int i = 0 ; i < devices . Length ; i++ )
144+ newDevices[ i ] = devices [ i ] ;
145+ newDevices[ devices . Length ] = "OpenVR" ;
146+ updated = true ;
147+ }
145148#if ( UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0 )
146- UnityEditorInternal . VR . VREditor . SetVREnabledDevices ( BuildTargetGroup . Standalone , newDevices ) ;
149+ UnityEditorInternal . VR . VREditor . SetVREnabledDevices ( BuildTargetGroup . Standalone , newDevices ) ;
147150#else
148- UnityEditorInternal . VR . VREditor . SetVREnabledDevicesOnTargetGroup ( BuildTargetGroup . Standalone , newDevices ) ;
151+ UnityEditorInternal . VR . VREditor . SetVREnabledDevicesOnTargetGroup ( BuildTargetGroup . Standalone , newDevices ) ;
149152#endif
150- }
153+ }
151154
152- if ( updated )
153- Debug. Log ( "Switching to native OpenVR support." ) ;
155+ if ( updated )
156+ Debug. Log ( "Switching to native OpenVR support." ) ;
157+ }
154158
155159 var dlls = new string [ ]
156160 {
@@ -175,8 +179,7 @@ static void Update()
175179 }
176180
177181 Vector2 scrollPosition;
178- bool toggleState;
179-
182+
180183 string GetResourcePath ( )
181184 {
182185 var ms = MonoScript. FromScriptableObject( this ) ;
0 commit comments