Skip to content

Commit 0a13378

Browse files
authored
FIX: Escape the ampersand character from Control Scheme dropdown menu on Windows platform (#2050)
* Escape the ampersand character on Windows platform for ControlSchemesMenu * Update CHANGELOG.md
1 parent a0219d1 commit 0a13378

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ however, it has to be formatted properly to pass verification tests.
2222
- Fixed missing documentation for source generated Input Action Assets. This is now generated as part of the source code generation step when "Generate C# Class" is checked in the importer inspector settings.
2323
- Fixed pasting into an empty map list raising an exception. [ISXB-1150](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1150)
2424
- Fixed pasting bindings into empty Input Action asset. [ISXB-1180](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1180)
25+
- Fixed missing '&' symbol in Control Scheme dropdown on Windows platform. [ISXB-1109](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1109)
2526

2627
### Changed
2728
- Added back the InputManager to InputSystem project-wide asset migration code with performance improvement (ISX-2086).

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ public override void RedrawUI(ViewState viewState)
138138
m_SaveButton.SetEnabled(InputEditorUserSettings.autoSaveInputActionAssets == false);
139139
}
140140

141+
private string SetupControlSchemeName(string name)
142+
{
143+
//On Windows the '&' is considered an accelerator character and will always be stripped.
144+
//Since the ControlScheme menu isn't creating hotkeys, it can be safely assumed that they are meant to be text
145+
//so we want to escape the character for MenuItem
146+
if (Application.platform == RuntimePlatform.WindowsEditor)
147+
{
148+
name = name.Replace("&", "&&");
149+
}
150+
return name;
151+
}
152+
141153
private void SetUpControlSchemesMenu(ViewState viewState)
142154
{
143155
m_ControlSchemesToolbar.menu.MenuItems().Clear();
@@ -151,7 +163,7 @@ private void SetUpControlSchemesMenu(ViewState viewState)
151163
m_ControlSchemesToolbar.menu.AppendAction("All Control Schemes", _ => SelectControlScheme(-1),
152164
viewState.selectedControlSchemeIndex == -1 ? DropdownMenuAction.Status.Checked : DropdownMenuAction.Status.Normal);
153165
viewState.controlSchemes.ForEach((scheme, i) =>
154-
m_ControlSchemesToolbar.menu.AppendAction(scheme.name, _ => SelectControlScheme(i),
166+
m_ControlSchemesToolbar.menu.AppendAction(SetupControlSchemeName(scheme.name), _ => SelectControlScheme(i),
155167
viewState.selectedControlSchemeIndex == i ? DropdownMenuAction.Status.Checked : DropdownMenuAction.Status.Normal));
156168
m_ControlSchemesToolbar.menu.AppendSeparator();
157169
}

0 commit comments

Comments
 (0)