Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Assets/Tests/InputSystem/CoreTests_Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3474,6 +3474,37 @@
});
}

[Test]
[Category("Editor")]
public void Editor_InputControlPicker_SearchDoesNotContainDuplicatePaths()
{
var dropdown = new StubInputControlPickerDropdown(new InputControlPickerState(), _ => {});
var root = dropdown.BuildRoot();

var searchableItems = new List<InputControlDropdownItem>();
void CollectSearchableLeaves(UnityEngine.InputSystem.Editor.AdvancedDropdownItem item)
{
if (!item.children.Any())
{
if (item is InputControlDropdownItem controlItem && controlItem.searchableName.Length > 0)
searchableItems.Add(controlItem);
return;
}
foreach (var child in item.children)
CollectSearchableLeaves(child);
}

CollectSearchableLeaves(root);

var duplicatePaths = searchableItems
.GroupBy(i => i.controlPathWithDevice)
.Where(g => g.Count() > 1)
.Select(g => g.Key)

Check warning on line 3502 in Assets/Tests/InputSystem/CoreTests_Editor.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Assets/Tests/InputSystem/CoreTests_Editor.cs#L3502

Added line #L3502 was not covered by tests
.ToList();
Assert.That(searchableItems.Select(i => i.controlPathWithDevice), Has.Some.EqualTo("<Mouse>/{Back}"));
Assert.That(duplicatePaths, Is.Empty);
}

internal class StubInputControlPickerDropdown : InputControlPickerDropdown
{
public StubInputControlPickerDropdown(InputControlPickerState state, Action<string> onPickCallback,
Expand Down
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed actions enabled during startup, for example in an Entities system's `OnCreate`, being disabled when entering Play Mode with domain reload disabled and in Player builds. [UUM-151403](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-151403)
- Fixed the Player Input component Inspector not showing the action map events after the Behavior is set to Invoke Unity Events, until the GameObject was selected again. [UUM-150956](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-150956)
- Fixed a control declared for several variants at once (for example `"variants" : "A;B"`) only merging with derived layouts under its first variant; derived overrides for the other variants lost the base control's layout, offset, format and usages. [UUM-160829](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-160829)
- Fixed duplicate entries appearing in the Input Actions Editor binding path search for some devices, such as Mouse and XR controllers. [UUM-160646](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-160646)

## [1.20.1] - 2026-10-05

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ private string BuildControlPath()
return base.controlPathWithDevice;
}

public ControlUsageDropdownItem(string device, string usage, string controlUsage)
public ControlUsageDropdownItem(string device, string usage, string controlUsage, bool searchable = true)
: base(usage)
{
m_Device = string.IsNullOrEmpty(device) ? "*" : device;
m_Usage = usage;
m_ControlPath = $"{{{ controlUsage }}}";
name = controlUsage;
id = controlPathWithDevice.GetHashCode();
m_Searchable = true;
m_Searchable = searchable;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ protected override void ItemSelected(AdvancedDropdownItem item)
m_OnPickCallback(path);
}

private AdvancedDropdownItem BuildTreeForControlUsages(string device = "", string usage = "")
private AdvancedDropdownItem BuildTreeForControlUsages(string device = "", string usage = "", bool searchable = true)
{
var usageRoot = new AdvancedDropdownItem("Usages");
foreach (var usageAndLayouts in EditorInputControlLayoutCache.allUsages)
{
if (usageAndLayouts.Item2.Any(LayoutMatchesExpectedControlLayoutFilter))
{
var child = new ControlUsageDropdownItem(device, usage, usageAndLayouts.Item1);
var child = new ControlUsageDropdownItem(device, usage, usageAndLayouts.Item1, searchable);
usageRoot.AddChild(child);
}
}
Expand Down Expand Up @@ -193,7 +193,7 @@ private void AddDeviceTreeItemRecursive(InputControlLayout layout, AdvancedDropd
var usageItem = new DeviceDropdownItem(layout, usage);

// Add control usages to the device variants
var deviceVariantControlUsages = BuildTreeForControlUsages(layout.name, usage);
var deviceVariantControlUsages = BuildTreeForControlUsages(layout.name, usage, searchable);
if (deviceVariantControlUsages.children.Any())
{
usageItem.AddChild(deviceVariantControlUsages);
Expand All @@ -208,7 +208,7 @@ private void AddDeviceTreeItemRecursive(InputControlLayout layout, AdvancedDropd
}

// Add control usages
var deviceControlUsages = BuildTreeForControlUsages(layout.name);
var deviceControlUsages = BuildTreeForControlUsages(layout.name, searchable: searchable);
if (deviceControlUsages.children.Any())
{
deviceItem.AddChild(deviceControlUsages);
Expand Down
Loading