Skip to content

Commit 6483067

Browse files
committed
Prevent paste of composite parts into bindings
1 parent ca0d36f commit 6483067

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

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 (location.item is not CompositeBindingTreeItem && tag == k_PartOfCompositeBindingTag)
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)