Skip to content

Commit 50b0592

Browse files
authored
FIX: DefaultActionMap dropdown set to <None> by default (ISXB-1559) (#2194)
1 parent f010d4c commit 50b0592

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ however, it has to be formatted properly to pass verification tests.
3131
- Fixed PlayerInput component automatically switching away from the default ActionMap set to 'None'.
3232
- Fixed a console error being shown when targeting visionOS builds in 2022.3.
3333
- 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)
34+
- Fixed the defaultActionMap dropdown in the PlayerInput component defaulting to <None> instead of the first ActionMap.
3435
- 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)
3536
- 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.
3637

Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@ public override void OnInspectorGUI()
9696
}
9797
}
9898
#endif
99-
if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || CheckIfActionAssetChanged())
99+
var assetChanged = CheckIfActionAssetChanged();
100+
// initialize the editor component if the asset has changed or if it has not been initialized yet
101+
if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || assetChanged || m_ActionAssetInstanceID == 0)
100102
{
101-
OnActionAssetChange();
103+
InitializeEditorComponent(assetChanged);
102104
actionsWereChanged = true;
103105
}
104106

@@ -136,6 +138,7 @@ public override void OnInspectorGUI()
136138
// Restore the initial color
137139
GUI.backgroundColor = currentBg;
138140

141+
139142
rect = EditorGUILayout.GetControlRect();
140143
label = EditorGUI.BeginProperty(rect, m_AutoSwitchText, m_NeverAutoSwitchControlSchemesProperty);
141144
var neverAutoSwitchValueOld = m_NeverAutoSwitchControlSchemesProperty.boolValue;
@@ -277,7 +280,8 @@ bool CheckIfActionAssetChanged()
277280
if (m_ActionsProperty.objectReferenceValue != null)
278281
{
279282
var assetInstanceID = m_ActionsProperty.objectReferenceValue.GetInstanceID();
280-
bool result = assetInstanceID != m_ActionAssetInstanceID;
283+
// if the m_ActionAssetInstanceID is 0 the PlayerInputEditor has not been initialized yet, but the asset did not change
284+
bool result = assetInstanceID != m_ActionAssetInstanceID && m_ActionAssetInstanceID != 0;
281285
m_ActionAssetInstanceID = (int)assetInstanceID;
282286
return result;
283287
}
@@ -454,19 +458,21 @@ private void OnNotificationBehaviorChange()
454458
m_NotificationBehaviorInitialized = true;
455459
}
456460

457-
private void OnActionAssetChange()
461+
private void InitializeEditorComponent(bool assetChanged)
458462
{
459463
serializedObject.ApplyModifiedProperties();
460464
m_ActionAssetInitialized = true;
461465

462466
var playerInput = (PlayerInput)target;
463467
var asset = (InputActionAsset)m_ActionsProperty.objectReferenceValue;
468+
469+
if (assetChanged)
470+
m_SelectedDefaultActionMap = -1;
464471
if (asset == null)
465472
{
466473
m_ControlSchemeOptions = null;
467474
m_ActionMapOptions = null;
468475
m_ActionNames = null;
469-
m_SelectedDefaultActionMap = -1;
470476
m_SelectedDefaultControlScheme = -1;
471477
m_InvalidDefaultControlSchemeName = null;
472478
return;

0 commit comments

Comments
 (0)