Skip to content

Commit e888e90

Browse files
Ensure InputSystemObject exists and initializes to prevent nulls in play mode tests
1. Editor_InitializeInEditor_EnablesProjectWideActions 2. Editor_InputEventsOccurringWhileGoingIntoPlayMode_AreDiscarded 3. Editor_LeavingPlayMode_DestroysAllActionStates 4. Editor_LeavingPlayMode_DiscardsInputActionAssetChanges 5. Editor_LeavingPlayMode_RemovesAllInputUsersAndStopsListeningForUnpairedDeviceActivity
1 parent 9941866 commit e888e90

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Packages/com.unity.inputsystem/Editor/InputSystemEditorInitializer.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,14 @@ private static void OnEditorProjectChanged()
407407
/// </summary>
408408
internal static void OnPlayModeChange(PlayModeStateChange change)
409409
{
410+
// Tests may call this directly without going through the full editor initialization path.
411+
// Ensure we have a system object to store/restore transient editor state.
412+
if (s_SystemObject == null)
413+
{
414+
s_SystemObject = ScriptableObject.CreateInstance<InputSystemObject>();
415+
s_SystemObject.hideFlags = HideFlags.HideAndDontSave;
416+
}
417+
410418
switch (change)
411419
{
412420
case PlayModeStateChange.ExitingEditMode:

0 commit comments

Comments
 (0)