Skip to content

Commit e3a0cb7

Browse files
Address u-pr review feedback for UUM-141423
- Collapse the composite-part scan into a single loop. The original two-pass scan computed lastPartIndex but did not use it for outer-loop advancement, so merging the bounds check into the for-loop condition eliminates the redundant first pass without changing behaviour. - Reword the inline comment to reference the index-based GetBindingDisplayString overload by name instead of by line number, which goes stale as the file is edited. - Add Actions_WhenGettingDisplayTextForBindingsOnAction_MixedGroupCompositeIsRenderedAtomicallyWhenAnyPartMatchesBindingMask covering a mixed-group 1DAxis composite (Keyboard + Mouse parts) under both MaskByGroup("Keyboard") and MaskByGroup("Mouse"). Both masks must render the whole composite ("A/Left Button"), exercising the atomic-promotion claim. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 4769538 commit e3a0cb7

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

Assets/Tests/InputSystem/CoreTests_Actions.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9253,6 +9253,23 @@ public void Actions_WhenGettingDisplayTextForBindingsOnAction_CompositeIsInclude
92539253
Is.EqualTo("A/D"));
92549254
}
92559255

9256+
// https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-141423
9257+
[Test]
9258+
[Category("Actions")]
9259+
public void Actions_WhenGettingDisplayTextForBindingsOnAction_MixedGroupCompositeIsRenderedAtomicallyWhenAnyPartMatchesBindingMask()
9260+
{
9261+
var action = new InputAction();
9262+
9263+
action.AddCompositeBinding("1DAxis")
9264+
.With("Negative", "<Keyboard>/a", groups: "Keyboard")
9265+
.With("Positive", "<Mouse>/leftButton", groups: "Mouse");
9266+
9267+
Assert.That(action.GetBindingDisplayString(InputBinding.MaskByGroup("Keyboard")),
9268+
Is.EqualTo("A/Left Button"));
9269+
Assert.That(action.GetBindingDisplayString(InputBinding.MaskByGroup("Mouse")),
9270+
Is.EqualTo("A/Left Button"));
9271+
}
9272+
92569273
// https://fogbugz.unity3d.com/f/cases/1321175/
92579274
[Test]
92589275
[Category("Actions")]

Packages/com.unity.inputsystem/InputSystem/Runtime/Actions/InputActionRebindingExtensions.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -323,16 +323,13 @@ public static string GetBindingDisplayString(this InputAction action, InputBindi
323323
if (!bindingMask.Matches(bindings[i]))
324324
{
325325
// Composites are filtered atomically: any matching part promotes the whole
326-
// composite, consistent with how the integer-index renderer at lines 440-492
327-
// already treats composites as one display unit; per-part filtering would
328-
// require a separate API.
326+
// composite, consistent with how the index-based GetBindingDisplayString
327+
// overload below treats composites as one display unit; per-part filtering
328+
// would require a separate API.
329329
if (!bindings[i].isComposite)
330330
continue;
331-
var lastPartIndex = i + 1;
332-
while (lastPartIndex < bindings.Count && bindings[lastPartIndex].isPartOfComposite)
333-
++lastPartIndex;
334331
var anyPartMatches = false;
335-
for (var partIndex = i + 1; partIndex < lastPartIndex; ++partIndex)
332+
for (var partIndex = i + 1; partIndex < bindings.Count && bindings[partIndex].isPartOfComposite; ++partIndex)
336333
{
337334
if (bindingMask.Matches(bindings[partIndex]))
338335
{

0 commit comments

Comments
 (0)