diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs index 6f08da5045..667cbf7aa5 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs @@ -197,7 +197,9 @@ private void SetAsset(InputActionAsset asset, string actionToSelect = null, stri finally { if (existingWorkingCopy != null) + { DestroyImmediate(existingWorkingCopy); + } } } @@ -273,7 +275,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")); } @@ -366,7 +367,7 @@ 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); #endif @@ -447,8 +448,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 e6e7e58e5f..ce83b6d743 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( @@ -118,6 +125,7 @@ public override void RedrawUI(InputControlScheme viewState) public override void DestroyView() { + IsShowingControlSchemeView = false; m_ModalWindow.RemoveFromHierarchy(); } @@ -137,6 +145,8 @@ private 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. //