Skip to content

Commit b74c0aa

Browse files
committed
confirm changes to be saved before overwriting window asset
1 parent d3eae07 commit b74c0aa

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,28 @@ private static InputActionsEditorWindow OpenWindow(InputActionAsset asset, strin
100100
}
101101

102102
var window = GetWindow<InputActionsEditorWindow>();
103+
if (window.m_IsDirty)
104+
{
105+
var assetPath = AssetDatabase.GUIDToAssetPath(window.m_AssetGUID);
106+
if (!string.IsNullOrEmpty(assetPath))
107+
{
108+
// Prompt user with a dialog
109+
var result = Dialog.InputActionAsset.ShowSaveChanges(assetPath);
110+
switch (result)
111+
{
112+
case Dialog.Result.Save:
113+
window.Save(isAutoSave: false);
114+
break;
115+
case Dialog.Result.Cancel:
116+
return window;
117+
case Dialog.Result.Discard:
118+
break;
119+
default:
120+
throw new ArgumentOutOfRangeException(nameof(result));
121+
}
122+
}
123+
}
124+
103125
window.m_IsDirty = false;
104126
window.minSize = k_MinWindowSize;
105127
window.SetAsset(asset, actionToSelect, actionMapToSelect);

0 commit comments

Comments
 (0)