@@ -2905,6 +2905,39 @@ private static void DisableProjectWideActions()
29052905#endif
29062906 }
29072907
2908+ [ Test ]
2909+ [ Category ( "Editor" ) ]
2910+ public void Editor_InitializeInEditor_EnablesProjectWideActions ( )
2911+ {
2912+ #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
2913+ if ( InputSystem . actions != null )
2914+ {
2915+ // Asserts that project wide actions are enabled by default.
2916+ // Before the test is run, InputSystem.Reset() is called which will enable them.
2917+ // It can be interpreted as a mock of the behavior that happens when `InitializeInEditor()` is called.
2918+ Assert . That ( InputSystem . actions . enabled , Is . True ) ;
2919+
2920+ // Calling exit play mode callbacks will disable them
2921+ InputSystem . OnPlayModeChange ( PlayModeStateChange . ExitingPlayMode ) ;
2922+ InputSystem . OnPlayModeChange ( PlayModeStateChange . EnteredEditMode ) ;
2923+
2924+ Assert . That ( InputSystem . actions . enabled , Is . False ) ;
2925+
2926+ // Calling enter play mode callbacks will not re-enable them per default. They are only
2927+ // enabled when `InputSystem.InitializeInEditor()` is called, which happens before these callbacks.
2928+ // Note: Project-wide actions are disabled at this point. These next lines are added to make sure we
2929+ // establish behavior that project-wide actions should be enabled only once
2930+ // `InputSystem.InitializeInEditor()` is called. Before this test was introduced, project-wide actions were
2931+ // enabled after entering play mode again which would lead to a different behavior than Player
2932+ // builds.
2933+ InputSystem . OnPlayModeChange ( PlayModeStateChange . ExitingEditMode ) ;
2934+ InputSystem . OnPlayModeChange ( PlayModeStateChange . EnteredPlayMode ) ;
2935+
2936+ Assert . That ( InputSystem . actions . enabled , Is . False ) ;
2937+ }
2938+ #endif
2939+ }
2940+
29082941 [ Test ]
29092942 [ Category ( "Editor" ) ]
29102943 public void Editor_LeavingPlayMode_DestroysAllActionStates ( )
@@ -2920,6 +2953,7 @@ public void Editor_LeavingPlayMode_DestroysAllActionStates()
29202953 InputSystem . OnPlayModeChange ( PlayModeStateChange . ExitingEditMode ) ;
29212954
29222955#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
2956+
29232957 // This simulates enabling project-wide actions, which is done before just before entering play mode,
29242958 // called from InputSystem.InitializeInEditor().
29252959 if ( InputSystem . actions )
0 commit comments