File tree Expand file tree Collapse file tree 3 files changed +22
-6
lines changed
Packages/com.unity.inputsystem/InputSystem Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -4237,6 +4237,13 @@ internal struct GlobalState
42374237
42384238 internal static GlobalState s_GlobalState ;
42394239
4240+ [ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . BeforeSceneLoad ) ]
4241+ private static void InitializeGlobalActionState ( )
4242+ {
4243+ ResetGlobals ( ) ;
4244+ s_GlobalState = default ;
4245+ }
4246+
42404247 internal static ISavedState SaveAndResetState ( )
42414248 {
42424249 // Save current state
Original file line number Diff line number Diff line change @@ -593,12 +593,14 @@ internal struct GlobalState
593593#endif
594594 }
595595
596- private static GlobalState CreateGlobalState ( )
597- { // Convenient method since parameterized construction is default
598- return new GlobalState { historyLengthPerFinger = 64 } ;
599- }
596+ internal static GlobalState s_GlobalState ;
600597
601- internal static GlobalState s_GlobalState = CreateGlobalState ( ) ;
598+ [ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . BeforeSceneLoad ) ]
599+ private static void InitializeGlobalTouchState ( )
600+ {
601+ // Touch GlobalState doesn't require Dispose operations
602+ s_GlobalState = new GlobalState { historyLengthPerFinger = 64 } ;
603+ }
602604
603605 internal static ISavedState SaveAndResetState ( )
604606 {
@@ -609,7 +611,7 @@ internal static ISavedState SaveAndResetState()
609611 ( ) => { /* currently nothing to dispose */ } ) ;
610612
611613 // Reset global state
612- s_GlobalState = CreateGlobalState ( ) ;
614+ InitializeGlobalTouchState ( ) ;
613615
614616 return savedState ;
615617 }
Original file line number Diff line number Diff line change @@ -1873,6 +1873,13 @@ private struct GlobalState
18731873
18741874 private static GlobalState s_GlobalState ;
18751875
1876+ [ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . BeforeSceneLoad ) ]
1877+ private static void InitializeGlobalUserState ( )
1878+ {
1879+ ResetGlobals ( ) ;
1880+ s_GlobalState = default ;
1881+ }
1882+
18761883 internal static ISavedState SaveAndResetState ( )
18771884 {
18781885 // Save current state and provide an opaque interface to restore it
You can’t perform that action at this time.
0 commit comments