Skip to content

Commit b2a2329

Browse files
authored
FIX: Prevent composite parts being pasted into non-composites (#2153)
1 parent 8fe669c commit b2a2329

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ however, it has to be formatted properly to pass verification tests.
1313
### Fixed
1414
- Fixed an issue where all action maps were enabled initially for project wide actions, which overrode the PlayerInput action map configuration. [ISXB-920](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-920)
1515
- Fixed an issue where ButtonStates are not fully updated when switching SingleUnifiedPointer. [ISXB-1356](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1356)
16+
- Fixed errors when pasting composite parts into non-composites. [ISXB-757](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-757)
1617

1718
### Changed
1819
- Changed enum value `Key.IMESelected` to obsolete which was not a real key. Please use the ButtonControl `imeSelected`.

Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputActionTreeView.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,10 @@ Type CopyTagToType(string tagName)
795795
var itemType = CopyTagToType(tag);
796796
if (location.item is ActionTreeItemBase dropTarget)
797797
{
798+
// Specific case - Composite parts cannot be dropped into Bindings
799+
if (tag == k_PartOfCompositeBindingTag && location.item is not(CompositeBindingTreeItem or PartOfCompositeBindingTreeItem))
800+
return;
801+
798802
if (!dropTarget.GetDropLocation(itemType, location.childIndex, ref array, ref arrayIndex))
799803
return;
800804
}

Packages/com.unity.inputsystem/InputSystem/Editor/AssetEditor/InputBindingPropertiesView.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,16 @@ protected override void DrawGeneralProperties()
9494
if (m_CompositeParts == null)
9595
InitializeCompositePartProperties();
9696

97-
var selectedPart = EditorGUILayout.Popup(s_CompositePartAssignmentLabel, m_SelectedCompositePart,
98-
m_CompositePartOptions);
99-
if (selectedPart != m_SelectedCompositePart)
97+
// If m_CompositeParts still null after InitializeCompositePartProperties something went wrong and we can't select
98+
if (m_CompositeParts != null)
10099
{
101-
m_SelectedCompositePart = selectedPart;
102-
OnCompositePartAssignmentChanged();
100+
var selectedPart = EditorGUILayout.Popup(s_CompositePartAssignmentLabel, m_SelectedCompositePart,
101+
m_CompositePartOptions);
102+
if (selectedPart != m_SelectedCompositePart)
103+
{
104+
m_SelectedCompositePart = selectedPart;
105+
OnCompositePartAssignmentChanged();
106+
}
103107
}
104108
}
105109

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/Commands.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ public static Command PasteActionsOrBindings(List<IPasteListener> pasteListeners
266266
else
267267
lastPastedElement = CopyPasteHelper.PasteActionsOrBindingsFromClipboard(state.With(selectedBindingIndex: newIndex >= 0 ? newIndex : state.selectedBindingIndex));
268268

269-
lastPastedElement.FindPropertyRelative("m_Action").stringValue = relatedAction.Value.name;
269+
if (lastPastedElement != null)
270+
lastPastedElement.FindPropertyRelative("m_Action").stringValue = relatedAction.Value.name;
270271
}
271272
}
272273

0 commit comments

Comments
 (0)