@@ -45,7 +45,9 @@ public class Plugin : IBeatSaberPlugin
45
45
46
46
private HarmonyInstance _harmonyInstance ;
47
47
48
- private readonly HashSet < EVREventType > pauseEvents = new HashSet < EVREventType > ( new [ ] { EVREventType . VREvent_InputFocusCaptured , EVREventType . VREvent_DashboardActivated , EVREventType . VREvent_OverlayShown } ) ;
48
+ private readonly HashSet < EVREventType > _pauseEvents = new HashSet < EVREventType > ( new [ ] { EVREventType . VREvent_InputFocusCaptured , EVREventType . VREvent_DashboardActivated , EVREventType . VREvent_OverlayShown } ) ;
49
+
50
+ private bool _initialized ;
49
51
50
52
public void Init ( Logger logger )
51
53
{
@@ -68,6 +70,8 @@ public void OnApplicationStart()
68
70
AddManifestToSteamConfig ( ) ;
69
71
RegisterActionSet ( ) ;
70
72
ApplyHarmonyPatches ( ) ;
73
+
74
+ _initialized = true ;
71
75
}
72
76
catch ( Exception ex )
73
77
{
@@ -79,13 +83,13 @@ public void OnApplicationStart()
79
83
public void OnApplicationQuit ( )
80
84
{
81
85
// not really necessary here, just following good practices
82
- leftTriggerValue . Dispose ( ) ;
83
- rightTriggerValue . Dispose ( ) ;
84
- menu . Dispose ( ) ;
85
- leftSlice . Dispose ( ) ;
86
- rightSlice . Dispose ( ) ;
87
- leftHandPose . Dispose ( ) ;
88
- rightHandPose . Dispose ( ) ;
86
+ leftTriggerValue ? . Dispose ( ) ;
87
+ rightTriggerValue ? . Dispose ( ) ;
88
+ menu ? . Dispose ( ) ;
89
+ leftSlice ? . Dispose ( ) ;
90
+ rightSlice ? . Dispose ( ) ;
91
+ leftHandPose ? . Dispose ( ) ;
92
+ rightHandPose ? . Dispose ( ) ;
89
93
}
90
94
91
95
private void AddManifestToSteamConfig ( )
@@ -248,10 +252,13 @@ public void OnSceneUnloaded(Scene scene) { }
248
252
249
253
public void OnUpdate ( )
250
254
{
251
- VREvent_t evt = default ;
252
- if ( OpenVR . System . PollNextEvent ( ref evt , ( uint ) Marshal . SizeOf ( typeof ( VREvent_t ) ) ) && pauseEvents . Contains ( ( EVREventType ) evt . eventType ) )
255
+ if ( _initialized )
253
256
{
254
- Resources . FindObjectsOfTypeAll < PauseController > ( ) . FirstOrDefault ( ) ? . Pause ( ) ;
257
+ VREvent_t evt = default ;
258
+ if ( OpenVR . System . PollNextEvent ( ref evt , ( uint ) Marshal . SizeOf ( typeof ( VREvent_t ) ) ) && _pauseEvents . Contains ( ( EVREventType ) evt . eventType ) )
259
+ {
260
+ Resources . FindObjectsOfTypeAll < PauseController > ( ) . FirstOrDefault ( ) ? . Pause ( ) ;
261
+ }
255
262
}
256
263
}
257
264
}
0 commit comments