Skip to content

Commit 47bed00

Browse files
authored
CHANGE: Auto-save on focus lost can no longer be compiled out (#2282)
1 parent d45fba4 commit 47bed00

File tree

4 files changed

+3
-37
lines changed

4 files changed

+3
-37
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ however, it has to be formatted properly to pass verification tests.
1313
### Changed
1414
- Project-Wide Input Actions support can no longer be disabled (removed the UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS define). (ISX-2397)
1515
- Removed code that had to do with Unity versions older than Unity 2022.3 LTS. (ISX-2396)
16+
- Auto-save on focus lost can no longer be compiled out (ISX-2397)
1617

1718
### Fixed
1819
- An issue where a UITK MouseEvent was triggered when changing from Scene View to Game View in the Editor has been fixed. [ISXB-1671](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1671)

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,9 @@ private void OnFocusIn(FocusInEvent @event = null)
118118

119119
void SaveAssetOnFocusLost()
120120
{
121-
#if UNITY_INPUT_SYSTEM_INPUT_ACTIONS_EDITOR_AUTO_SAVE_ON_FOCUS_LOST
122121
var asset = GetAsset();
123122
if (asset != null)
124123
ValidateAndSaveAsset(asset);
125-
#endif
126124
}
127125

128126
public static void SetIMGUIDropdownVisible(bool visible, bool optionWasSelected)
@@ -175,18 +173,6 @@ private void OnFocusOut(FocusOutEvent @event = null)
175173
DelayFocusLost(element == null);
176174
}
177175

178-
private void OnStateChanged(InputActionsEditorState newState, UIRebuildMode editorRebuildMode)
179-
{
180-
#if UNITY_INPUT_SYSTEM_INPUT_ACTIONS_EDITOR_AUTO_SAVE_ON_FOCUS_LOST
181-
// No action, auto-saved on edit-focus lost
182-
#else
183-
// Project wide input actions always auto save - don't check the asset auto save status
184-
var asset = GetAsset();
185-
if (asset != null)
186-
ValidateAndSaveAsset(asset);
187-
#endif
188-
}
189-
190176
private void ValidateAndSaveAsset(InputActionAsset asset)
191177
{
192178
ProjectWideActionsAsset.Verify(asset); // Ignore verification result for save
@@ -259,7 +245,6 @@ private void BuildUI()
259245
if (hasAsset)
260246
{
261247
m_StateContainer = new StateContainer(m_State, AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(asset)));
262-
m_StateContainer.StateChanged += OnStateChanged;
263248
m_View = new InputActionsEditorView(m_RootVisualElement, m_StateContainer, true, null);
264249
m_StateContainer.Initialize(m_RootVisualElement.Q("action-editor"));
265250
}

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,6 @@ private void OnStateChanged(InputActionsEditorState newState, UIRebuildMode edit
267267
{
268268
DirtyInputActionsEditorWindow(newState);
269269
m_State = newState;
270-
271-
#if UNITY_INPUT_SYSTEM_INPUT_ACTIONS_EDITOR_AUTO_SAVE_ON_FOCUS_LOST
272-
// No action taken apart from setting dirty flag, auto-save triggered as part of having a dirty asset
273-
// and editor loosing focus instead.
274-
#else
275-
if (InputEditorUserSettings.autoSaveInputActionAssets)
276-
Save(isAutoSave: false);
277-
#endif
278270
}
279271

280272
private void UpdateWindowTitle()
@@ -313,13 +305,7 @@ private bool HasContentChanged()
313305

314306
private void DirtyInputActionsEditorWindow(InputActionsEditorState newState)
315307
{
316-
#if UNITY_INPUT_SYSTEM_INPUT_ACTIONS_EDITOR_AUTO_SAVE_ON_FOCUS_LOST
317-
// Window is dirty is equivalent to if asset has changed
318308
var isWindowDirty = HasContentChanged();
319-
#else
320-
// Window is dirty is never true since every change is auto-saved
321-
var isWindowDirty = !InputEditorUserSettings.autoSaveInputActionAssets && HasContentChanged();
322-
#endif
323309

324310
if (m_IsDirty == isWindowDirty)
325311
return;
@@ -345,16 +331,15 @@ private void OnFocus()
345331

346332
private void OnLostFocus()
347333
{
348-
// Auto-save triggers on focus-lost instead of on every change
349-
#if UNITY_INPUT_SYSTEM_INPUT_ACTIONS_EDITOR_AUTO_SAVE_ON_FOCUS_LOST
350334
if (InputEditorUserSettings.autoSaveInputActionAssets && m_IsDirty)
335+
{
351336
// We'd like to avoid saving in case the focus was lost due to the drop-down window being spawned.
352337
// This code should be cleaned up once we migrate the InputControl stuff from ImGUI completely.
353338
// Since at that point it stops being a separate window that steals focus.
354339
// (See case ISXB-1221)
355340
if (!InputControlPathEditor.IsShowingDropdown)
356341
Save(isAutoSave: true);
357-
#endif
342+
}
358343

359344
analytics.RegisterEditorFocusOut();
360345
}

Packages/com.unity.inputsystem/InputSystem/Unity.InputSystem.asmdef

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@
5252
"expression": "1.0.0",
5353
"define": "UNITY_INPUT_SYSTEM_ENABLE_UI"
5454
},
55-
{
56-
"name": "Unity",
57-
"expression": "1",
58-
"define": "UNITY_INPUT_SYSTEM_INPUT_ACTIONS_EDITOR_AUTO_SAVE_ON_FOCUS_LOST"
59-
},
6055
{
6156
"name": "Unity",
6257
"expression": "6000.0.9",

0 commit comments

Comments
 (0)