Skip to content

Commit eeec99e

Browse files
author
Rene Damm
authored
FIX: RegisterLayoutOverride causing 'extend' setting to be lost (case 1377719, #1452).
1 parent 54fd309 commit eeec99e

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

Assets/Tests/InputSystem/CoreTests_Layouts.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,49 @@ public void Layouts_CanApplyOverridesToOverrides()
972972
Assert.That(device["extraControl"].layout, Is.EqualTo("Axis"));
973973
}
974974

975+
// https://fogbugz.unity3d.com/f/cases/1377719/
976+
[Test]
977+
[Category("Layouts")]
978+
public void Layouts_ApplyingOverride_DoesNotAlterExistingInheritanceHierarchy()
979+
{
980+
const string baseLayout = @"
981+
{
982+
""name"" : ""BaseLayout"",
983+
""controls"" : [
984+
{ ""name"" : ""button1"", ""layout"" : ""Button"" }
985+
]
986+
}
987+
";
988+
const string derivedLayout = @"
989+
{
990+
""name"" : ""DerivedLayout"",
991+
""extend"" : ""BaseLayout"",
992+
""controls"" : [
993+
{ ""name"" : ""button2"", ""layout"" : ""Button"" }
994+
]
995+
}
996+
";
997+
const string derivedLayoutOverride = @"
998+
{
999+
""name"" : ""DerivedLayoutOverride"",
1000+
""extend"" : ""DerivedLayout"",
1001+
""controls"" : [
1002+
{ ""name"" : ""button3"", ""layout"" : ""Button"" }
1003+
]
1004+
}
1005+
";
1006+
1007+
InputSystem.RegisterLayout(baseLayout);
1008+
InputSystem.RegisterLayout(derivedLayout);
1009+
InputSystem.RegisterLayoutOverride(derivedLayoutOverride);
1010+
1011+
var layout = InputSystem.LoadLayout("DerivedLayout");
1012+
Assert.That(layout.baseLayouts, Is.EquivalentTo(new[] { new InternedString("BaseLayout") }));
1013+
1014+
var device = InputSystem.AddDevice("DerivedLayout");
1015+
Assert.That(new[] { 1, 2, 3 }.Select(i => device["button" + i]), Is.All.TypeOf<ButtonControl>());
1016+
}
1017+
9751018
[Test]
9761019
[Category("Layouts")]
9771020
public void Layouts_CanOverrideCommonUsagesOnExistingLayout()

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ however, it has to be formatted properly to pass verification tests.
2929
- Fixed DualSense on iOS not inheriting from `DualShockGamepad` ([case 1378308](https://issuetracker.unity3d.com/issues/input-dualsense-detection-ios)).
3030
- Fixed a device becoming `.current` (e.g. `Gamepad.current`, etc) when sending a new state event that contains no control changes (case 1377952).
3131
- Fixed calling `IsPressed` on an entire device returning `true` ([case 1374024](https://issuetracker.unity3d.com/issues/inputcontrol-dot-ispressed-always-returns-true-when-using-new-input-system)).
32+
- Fixed `InputSystem.RegisterLayoutOverride` resulting in the layout that overrides are being applied to losing the connection to its base layout ([case 1377719](https://fogbugz.unity3d.com/f/cases/1377719/)).
3233

3334
#### Actions
3435

Packages/com.unity.inputsystem/InputSystem/Controls/InputControlLayout.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,6 +2026,7 @@ public InputControlLayout TryLoadLayout(InternedString name, Dictionary<Interned
20262026
overrideLayout.isOverride = false;
20272027
overrideLayout.isGenericTypeOfDevice = layout.isGenericTypeOfDevice;
20282028
overrideLayout.m_Name = layout.name;
2029+
overrideLayout.m_BaseLayouts = layout.m_BaseLayouts;
20292030

20302031
layout = overrideLayout;
20312032
layout.m_AppliedOverrides.Append(overrideName);

0 commit comments

Comments
 (0)