Skip to content

Commit 387c1e2

Browse files
committed
fix up the input control picker sometimes not applying the values
1 parent dc55c4a commit 387c1e2

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Packages/com.unity.inputsystem/InputSystem/Editor/ControlPicker/InputControlPathEditor.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert
161161

162162
private void ShowDropdown(Rect rect, SerializedProperty serializedProperty, Action modifiedCallback)
163163
{
164-
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
164+
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
165165
InputActionsEditorSettingsProvider.SetIMGUIDropdownVisible(true, false);
166-
#endif
166+
#endif
167+
IsShowingDropdown = true;
168+
167169
if (m_PickerDropdown == null)
168170
{
169171
m_PickerDropdown = new InputControlPickerDropdown(
@@ -187,6 +189,8 @@ private void ShowDropdown(Rect rect, SerializedProperty serializedProperty, Acti
187189
m_PickerDropdown.SetExpectedControlLayout(m_ExpectedControlLayout);
188190

189191
m_PickerDropdown.Show(rect);
192+
193+
IsShowingDropdown = false;
190194
}
191195

192196
private void SetExpectedControlLayoutFromAttribute(SerializedProperty property)
@@ -209,6 +213,13 @@ private void SetExpectedControlLayoutFromAttribute(SerializedProperty property)
209213

210214
private InputControlPickerDropdown m_PickerDropdown;
211215
private readonly InputControlPickerState m_PickerState;
216+
217+
/// <summary>
218+
/// This property is only set from this class in order to communicate that we're showing the dropdown at the moment
219+
/// It's employed to skip auto-saving, because that complicates updating the internal SerializedProperties.
220+
/// Unfortunately, we can't use IMGUIDropdownVisible from the setings provider because of the early-out logic in there.
221+
/// </summary>
222+
public static bool IsShowingDropdown { get; private set; }
212223
}
213224
}
214225
#endif // UNITY_EDITOR

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,12 @@ private void OnLostFocus()
344344
// Auto-save triggers on focus-lost instead of on every change
345345
#if UNITY_INPUT_SYSTEM_INPUT_ACTIONS_EDITOR_AUTO_SAVE_ON_FOCUS_LOST
346346
if (InputEditorUserSettings.autoSaveInputActionAssets && m_IsDirty)
347-
Save(isAutoSave: true);
347+
// We'd like to avoid saving in case the focus was lost due to the drop-down window being spawned.
348+
// This code should be cleaned up once we migrate the InputControl stuff from ImGUI completely.
349+
// Since at that point it stops being a separate window that steals focus.
350+
// (See case ISXB-1221)
351+
if (!InputControlPathEditor.IsShowingDropdown)
352+
Save(isAutoSave: true);
348353
#endif
349354

350355
analytics.RegisterEditorFocusOut();

0 commit comments

Comments
 (0)