Skip to content

Commit 6331849

Browse files
authored
FIX: ISXB-1153 fix exception on paste to empty actionmap list (#2042)
* handle array length 0 correctly * guard bad values in GetBindingIndexBeforeAction
1 parent 8b860b7 commit 6331849

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ however, it has to be formatted properly to pass verification tests.
2020
- Fixed unexpected control scheme switch when using `OnScreenControl` and pointer based schemes which registed "Cancel" event on every frame.[ISXB-656](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-656).
2121
- Fixed an issue with The "Add Control Scheme..." popup window so that it now persists until any changes are explicitly Saved or Cancelled [case ISXB-1131](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1131).
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.
23+
- Fixed pasting into an empty map list raising an exception. [ISXB-1150](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1150)
2324

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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ internal static void PasteItems(string copyBufferString, int[] indicesToInsert,
243243
// Split buffer into transmissions and then into transmission blocks
244244
var copiedType = GetCopiedType(copyBufferString);
245245
int indexOffset = 0;
246+
// If the array is empty, make sure we insert at index 0
247+
if (arrayToInsertInto.arraySize == 0)
248+
indexOffset = -1;
246249
foreach (var transmission in copyBufferString.Substring(k_CopyPasteMarker.Length + k_TypeMarker[copiedType].Length)
247250
.Split(new[] {k_EndOfTransmission}, StringSplitOptions.RemoveEmptyEntries))
248251
{

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ public static int GetSelectedBindingIndexAfterCompositeBindings(InputActionsEdit
114114

115115
public static int GetBindingIndexBeforeAction(SerializedProperty arrayProperty, int indexToInsert, SerializedProperty bindingArrayToInsertTo)
116116
{
117-
Debug.Assert(indexToInsert >= 0 && indexToInsert <= arrayProperty.arraySize, "Invalid action index to insert bindings before.");
117+
// Need to guard against this case, as there is different behaviour when pasting actions vs actionmaps
118+
if (indexToInsert < 0)
119+
{
120+
return -1;
121+
}
122+
Debug.Assert(indexToInsert <= arrayProperty.arraySize, "Invalid action index to insert bindings before.");
118123
var offset = 1; //previous action offset
119124
while (indexToInsert - offset >= 0)
120125
{

0 commit comments

Comments
 (0)