Skip to content

Commit 3e30dda

Browse files
committed
guard bad values in GetBindingIndexBeforeAction
1 parent fc8f93d commit 3e30dda

File tree

1 file changed

+6
-1
lines changed
  • Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views

1 file changed

+6
-1
lines changed

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)