Skip to content

Commit

Permalink
FIX: Scheme Name in Control Scheme editor menu that gets reset when e…
Browse files Browse the repository at this point in the history
…diting 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
  • Loading branch information
bmalrat authored May 28, 2024
1 parent 0843014 commit 2cca081
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ however, it has to be formatted properly to pass verification tests.
- 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).
- Fixed resource designation for "d_InputControl" icon to address CI failure.
- 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).
- 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)
- 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).
- Fixed error thrown when Cancelling Control Scheme creation in Input Actions Editor.
- 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).

## [1.8.2] - 2024-04-29

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,21 @@ public ControlSchemesView(VisualElement root, StateContainer stateContainer, boo
{
Dispatch((in InputActionsEditorState state) =>
{
m_NewName = ControlSchemeCommands.MakeUniqueControlSchemeName(state,
((TextField)evt.currentTarget).value);
// If the name is the same as the current name, don't change it
var newName = ((TextField)evt.currentTarget).value.Trim();
if (string.IsNullOrEmpty(newName) || String.Compare(newName, state.selectedControlScheme.name) == 0)
{
m_NewName = String.Empty;
// write back the value to the text field if the name was empty
((TextField)evt.currentTarget).value = state.selectedControlScheme.name;
}
else
{
m_NewName = ControlSchemeCommands.MakeUniqueControlSchemeName(state, newName);
// write back the value to the text field if the name was not unique
((TextField)evt.currentTarget).value = m_NewName;
}

return state.With(selectedControlScheme: state.selectedControlScheme);
});
});
Expand Down Expand Up @@ -95,7 +108,7 @@ private void RemoveDeviceRequirement()

public override void RedrawUI(InputControlScheme viewState)
{
rootElement.Q<TextField>(kControlSchemeNameTextField).value = viewState.name;
rootElement.Q<TextField>(kControlSchemeNameTextField).value = string.IsNullOrEmpty(m_NewName) ? viewState.name : m_NewName;

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

m_NewName = "";
m_NewName = string.Empty;
OnClosing?.Invoke(this);
}

Expand Down

0 comments on commit 2cca081

Please sign in to comment.