diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs index d5b5d12094..d8f9d976a6 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs @@ -175,7 +175,15 @@ private void OnFocusOut(FocusOutEvent @event = null) private void ValidateAndSaveAsset(InputActionAsset asset) { - ProjectWideActionsAsset.Verify(asset); // Ignore verification result for save + // This code should be cleaned up once we migrate the InputControl stuff from ImGUI completely. + // Since at that point it stops being a separate window that steals focus. + // (See case ISXB-1713) + if (!InputEditorUserSettings.autoSaveInputActionAssets || ControlSchemesView.IsShowingControlSchemeView) + { + return; + } + + ProjectWideActionsAsset.Verify(asset); // Ignore verification result for save EditorHelpers.SaveAsset(AssetDatabase.GetAssetPath(asset), asset.ToJson()); } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs index ae6e80c63a..fdcb45b8db 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs @@ -256,7 +256,6 @@ private void BuildUI() if (!rootVisualElement.styleSheets.Contains(InputActionsEditorWindowUtils.theme)) rootVisualElement.styleSheets.Add(InputActionsEditorWindowUtils.theme); m_View = new InputActionsEditorView(rootVisualElement, m_StateContainer, false, () => Save(isAutoSave: false)); - m_StateContainer.Initialize(rootVisualElement.Q("action-editor")); } @@ -334,8 +333,10 @@ private void OnLostFocus() // This code should be cleaned up once we migrate the InputControl stuff from ImGUI completely. // Since at that point it stops being a separate window that steals focus. // (See case ISXB-1221) - if (!InputControlPathEditor.IsShowingDropdown) + if (!InputControlPathEditor.IsShowingDropdown || !ControlSchemesView.IsShowingControlSchemeView) + { Save(isAutoSave: true); + } } analytics.RegisterEditorFocusOut(); @@ -415,8 +416,7 @@ private bool TryUpdateFromAsset() var assetPath = AssetDatabase.GUIDToAssetPath(m_AssetGUID); if (assetPath == null) { - Debug.LogWarning( - $"Failed to open InputActionAsset with GUID {m_AssetGUID}. The asset might have been deleted."); + Debug.LogWarning($"Failed to open InputActionAsset with GUID {m_AssetGUID}. The asset might have been deleted."); return false; } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ControlSchemesView.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ControlSchemesView.cs index ba1550a9ef..8b1a7335dd 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ControlSchemesView.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ControlSchemesView.cs @@ -14,9 +14,16 @@ internal class ControlSchemesView : ViewBase private string m_NewName; public event Action> OnClosing; + /// + /// This property is only set from this class in order to communicate that we're showing the control schemes view at the moment + /// It's employed to skip auto-saving, because that complicates the save causing this window to close when adding a new device type. + /// + internal static bool IsShowingControlSchemeView { get; private set; } + public ControlSchemesView(VisualElement root, StateContainer stateContainer, bool updateExisting = false) : base(root, stateContainer) { + IsShowingControlSchemeView = true; m_UpdateExisting = updateExisting; var controlSchemeEditor = AssetDatabase.LoadAssetAtPath( @@ -117,6 +124,7 @@ public override void RedrawUI(InputControlScheme viewState) public override void DestroyView() { + IsShowingControlSchemeView = false; m_ModalWindow.RemoveFromHierarchy(); } @@ -136,6 +144,8 @@ internal void Cancel() private void CloseView() { + IsShowingControlSchemeView = false; + // Closing the View without explicitly selecting "Save" or "Cancel" holds the values in the // current UI state but won't persist them; the Asset Editor state isn't dirtied. //