diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index a7a8426a40..7848950890 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -31,6 +31,7 @@ however, it has to be formatted properly to pass verification tests. - Fixed PlayerInput component automatically switching away from the default ActionMap set to 'None'. - Fixed a console error being shown when targeting visionOS builds in 2022.3. - Fixed a Tap Interaction issue with analog controls. The Tap interaction would keep re-starting after timeout. [ISXB-627](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-627) +- Fixed the defaultActionMap dropdown in the PlayerInput component defaulting to instead of the first ActionMap. - Fixed TrackedPoseDriver stops updating position and rotation when device is added after its initialization. [ISXB-1555](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1555) - Fixed PlayerInput component not working with C# Wrappers (ISXB-1535). This reverted changes done to fix [ISXB-920](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-920) but users can now fix it themselves. diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs index baea5ef47f..cb5d9c89c8 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs @@ -96,9 +96,11 @@ public override void OnInspectorGUI() } } #endif - if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || CheckIfActionAssetChanged()) + var assetChanged = CheckIfActionAssetChanged(); + // initialize the editor component if the asset has changed or if it has not been initialized yet + if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || assetChanged || m_ActionAssetInstanceID == 0) { - OnActionAssetChange(); + InitializeEditorComponent(assetChanged); actionsWereChanged = true; } @@ -136,6 +138,7 @@ public override void OnInspectorGUI() // Restore the initial color GUI.backgroundColor = currentBg; + rect = EditorGUILayout.GetControlRect(); label = EditorGUI.BeginProperty(rect, m_AutoSwitchText, m_NeverAutoSwitchControlSchemesProperty); var neverAutoSwitchValueOld = m_NeverAutoSwitchControlSchemesProperty.boolValue; @@ -277,7 +280,8 @@ bool CheckIfActionAssetChanged() if (m_ActionsProperty.objectReferenceValue != null) { var assetInstanceID = m_ActionsProperty.objectReferenceValue.GetInstanceID(); - bool result = assetInstanceID != m_ActionAssetInstanceID; + // if the m_ActionAssetInstanceID is 0 the PlayerInputEditor has not been initialized yet, but the asset did not change + bool result = assetInstanceID != m_ActionAssetInstanceID && m_ActionAssetInstanceID != 0; m_ActionAssetInstanceID = (int)assetInstanceID; return result; } @@ -454,19 +458,21 @@ private void OnNotificationBehaviorChange() m_NotificationBehaviorInitialized = true; } - private void OnActionAssetChange() + private void InitializeEditorComponent(bool assetChanged) { serializedObject.ApplyModifiedProperties(); m_ActionAssetInitialized = true; var playerInput = (PlayerInput)target; var asset = (InputActionAsset)m_ActionsProperty.objectReferenceValue; + + if (assetChanged) + m_SelectedDefaultActionMap = -1; if (asset == null) { m_ControlSchemeOptions = null; m_ActionMapOptions = null; m_ActionNames = null; - m_SelectedDefaultActionMap = -1; m_SelectedDefaultControlScheme = -1; m_InvalidDefaultControlSchemeName = null; return;