Skip to content

Commit 8098917

Browse files
andrew-ocekcoh
andauthored
FIX: Renaming an input action should not consider action being renamed for uniqueness (#1551)
Co-authored-by: Håkan Sidenvall <[email protected]>
1 parent e2dd23f commit 8098917

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Assets/Tests/InputSystem/CoreTests_Editor.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,7 @@ public void Editor_RenamingAction_WillAutomaticallyEnsureUniqueNames()
23392339
var map = new InputActionMap("set1");
23402340
map.AddAction("actionA", binding: "<Gamepad>/leftStick");
23412341
map.AddAction("actionB");
2342+
map.AddAction("A");
23422343
var asset = ScriptableObject.CreateInstance<InputActionAsset>();
23432344
asset.AddActionMap(map);
23442345

@@ -2353,6 +2354,14 @@ public void Editor_RenamingAction_WillAutomaticallyEnsureUniqueNames()
23532354
Assert.That(map.actions[0].name, Is.EqualTo("actionB1"));
23542355
Assert.That(map.actions[0].bindings, Has.Count.EqualTo(1));
23552356
Assert.That(map.actions[0].bindings[0].action, Is.EqualTo("actionB1"));
2357+
2358+
// now check that unique renaming ignores the action being renamed, so A can be renamed to a and not a1.
2359+
var actionAProperty = mapProperty.FindPropertyRelative("m_Actions").GetArrayElementAtIndex(2);
2360+
2361+
InputActionSerializationHelpers.RenameAction(actionAProperty, mapProperty, "a");
2362+
obj.ApplyModifiedPropertiesWithoutUndo();
2363+
2364+
Assert.That(map.actions[2].name, Is.EqualTo("a"));
23562365
}
23572366

23582367
[Test]

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ however, it has to be formatted properly to pass verification tests.
7878
### Fixed
7979
- Fix UI sometimes ignoring the first mouse click event after losing and regaining focus ([case ISXB-127](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-127).
8080
- Fixed issue when using MultiplayerEventSystems where the visual state of UI controls would change due to constant toggling of CanvasGroup.interactable on and off ([case ISXB-112](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-112)).
81+
- Fixed minor issue when renaming input actions where unique renaming would incorrectly consider the input action being renamed as a different action and not allow renaming of 'A' to 'a' without appending a unique integer for example ([case ISXB-25](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-25)).
8182
- Fixed an issue where the Input Action asset icon would not be visible during asset creation ([case ISXB-6](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-6)).
8283
- Fixed DualSense low frequency motor speed being always set to min value.
8384
- Fixed an issue where `ReadUnprocessedValueFromState` in PoseControl always returning default values.

Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputActionSerializationHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public static void RenameAction(SerializedProperty actionProperty, SerializedPro
416416
{
417417
// Make sure name is unique.
418418
var actionsArrayProperty = actionMapProperty.FindPropertyRelative("m_Actions");
419-
var uniqueName = FindUniqueName(actionsArrayProperty, newName);
419+
var uniqueName = FindUniqueName(actionsArrayProperty, newName, actionProperty.GetIndexOfArrayElement());
420420

421421
// Update all bindings that refer to the action.
422422
var nameProperty = actionProperty.FindPropertyRelative("m_Name");

0 commit comments

Comments
 (0)