Skip to content

Commit 55bc806

Browse files
FIX: Autosave closes add control scheme ui element on save. (ISXB-1713) (#2268)
1 parent 3b7340f commit 55bc806

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,15 @@ private void OnFocusOut(FocusOutEvent @event = null)
175175

176176
private void ValidateAndSaveAsset(InputActionAsset asset)
177177
{
178-
ProjectWideActionsAsset.Verify(asset); // Ignore verification result for save
178+
// This code should be cleaned up once we migrate the InputControl stuff from ImGUI completely.
179+
// Since at that point it stops being a separate window that steals focus.
180+
// (See case ISXB-1713)
181+
if (!InputEditorUserSettings.autoSaveInputActionAssets || m_View.IsControlSchemeViewActive())
182+
{
183+
return;
184+
}
185+
186+
ProjectWideActionsAsset.Verify(asset); // Ignore verification result for save
179187
EditorHelpers.SaveAsset(AssetDatabase.GetAssetPath(asset), asset.ToJson());
180188
}
181189

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ private void BuildUI()
256256
if (!rootVisualElement.styleSheets.Contains(InputActionsEditorWindowUtils.theme))
257257
rootVisualElement.styleSheets.Add(InputActionsEditorWindowUtils.theme);
258258
m_View = new InputActionsEditorView(rootVisualElement, m_StateContainer, false, () => Save(isAutoSave: false));
259-
260259
m_StateContainer.Initialize(rootVisualElement.Q("action-editor"));
261260
}
262261

@@ -334,8 +333,10 @@ private void OnLostFocus()
334333
// This code should be cleaned up once we migrate the InputControl stuff from ImGUI completely.
335334
// Since at that point it stops being a separate window that steals focus.
336335
// (See case ISXB-1221)
337-
if (!InputControlPathEditor.IsShowingDropdown)
336+
if (!InputControlPathEditor.IsShowingDropdown && !m_View.IsControlSchemeViewActive())
337+
{
338338
Save(isAutoSave: true);
339+
}
339340
}
340341

341342
analytics.RegisterEditorFocusOut();
@@ -415,8 +416,7 @@ private bool TryUpdateFromAsset()
415416
var assetPath = AssetDatabase.GUIDToAssetPath(m_AssetGUID);
416417
if (assetPath == null)
417418
{
418-
Debug.LogWarning(
419-
$"Failed to open InputActionAsset with GUID {m_AssetGUID}. The asset might have been deleted.");
419+
Debug.LogWarning($"Failed to open InputActionAsset with GUID {m_AssetGUID}. The asset might have been deleted.");
420420
return false;
421421
}
422422

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/InputActionsEditorView.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ private void CloseControlSchemeView()
115115
m_ControlSchemesView?.Cancel();
116116
}
117117

118+
public bool IsControlSchemeViewActive()
119+
{
120+
return m_ControlSchemesView != null;
121+
}
122+
118123
private void OnReset()
119124
{
120125
Dispatch(Commands.ReplaceActionMaps(ProjectWideActionsAsset.GetDefaultAssetJson()));
@@ -238,6 +243,7 @@ private void ShowControlSchemeEditor(VisualElement parent, bool updateExisting =
238243
{
239244
m_ControlSchemesView = CreateChildView(new ControlSchemesView(parent, stateContainer, updateExisting));
240245
m_ControlSchemesView.UpdateView(stateContainer.GetState());
246+
241247
m_ControlSchemesView.OnClosing += _ =>
242248
{
243249
DestroyChildView(m_ControlSchemesView);

0 commit comments

Comments
 (0)