Skip to content

Commit 2cca081

Browse files
authored
FIX: Scheme Name in Control Scheme editor menu that gets reset when editing devices (ISXB-763) (#1941)
* Fixed Scheme Name in Control Scheme editor menu that gets reset when editing devices * Added if we empty the name, it restore the initial name
1 parent 0843014 commit 2cca081

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ however, it has to be formatted properly to pass verification tests.
1515
- Fixed an issue where a composite binding would not be consecutively triggered after ResetDevice() has been called from the associated action handler [ISXB-746](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-746).
1616
- Fixed resource designation for "d_InputControl" icon to address CI failure.
1717
- Fixed an issue where a composite binding would not be consecutively triggered after disabling actions while there are action modifiers in progress [ISXB-505](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-505).
18-
- Fixed prefabs and missing default control scheme used by PlayerInput component are now correctly shown in the inspector [ISXB-818](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-818)
18+
- Fixed prefabs and missing default control scheme used by PlayerInput component are now correctly shown in the inspector [ISXB-818](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-818).
1919
- Fixed error thrown when Cancelling Control Scheme creation in Input Actions Editor.
20+
- Fixed Scheme Name in Control Scheme editor menu that gets reset when editing devices [ISXB-763](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-763).
2021

2122
## [1.8.2] - 2024-04-29
2223

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,21 @@ public ControlSchemesView(VisualElement root, StateContainer stateContainer, boo
3131
{
3232
Dispatch((in InputActionsEditorState state) =>
3333
{
34-
m_NewName = ControlSchemeCommands.MakeUniqueControlSchemeName(state,
35-
((TextField)evt.currentTarget).value);
34+
// If the name is the same as the current name, don't change it
35+
var newName = ((TextField)evt.currentTarget).value.Trim();
36+
if (string.IsNullOrEmpty(newName) || String.Compare(newName, state.selectedControlScheme.name) == 0)
37+
{
38+
m_NewName = String.Empty;
39+
// write back the value to the text field if the name was empty
40+
((TextField)evt.currentTarget).value = state.selectedControlScheme.name;
41+
}
42+
else
43+
{
44+
m_NewName = ControlSchemeCommands.MakeUniqueControlSchemeName(state, newName);
45+
// write back the value to the text field if the name was not unique
46+
((TextField)evt.currentTarget).value = m_NewName;
47+
}
48+
3649
return state.With(selectedControlScheme: state.selectedControlScheme);
3750
});
3851
});
@@ -95,7 +108,7 @@ private void RemoveDeviceRequirement()
95108

96109
public override void RedrawUI(InputControlScheme viewState)
97110
{
98-
rootElement.Q<TextField>(kControlSchemeNameTextField).value = viewState.name;
111+
rootElement.Q<TextField>(kControlSchemeNameTextField).value = string.IsNullOrEmpty(m_NewName) ? viewState.name : m_NewName;
99112

100113
m_ListView.itemsSource?.Clear();
101114
m_ListView.itemsSource = viewState.deviceRequirements.Count > 0 ?
@@ -133,7 +146,7 @@ private void CloseView()
133146
// the changes retained. However, if a different ControlScheme is selected or the Asset
134147
// Editor window is closed, then the changes are lost.
135148

136-
m_NewName = "";
149+
m_NewName = string.Empty;
137150
OnClosing?.Invoke(this);
138151
}
139152

0 commit comments

Comments
 (0)