@@ -22,11 +22,28 @@ internal static class CopyPasteHelper
22
22
23
23
private static SerializedProperty s_lastAddedElement ;
24
24
private static InputActionsEditorState s_State ;
25
+ private static bool s_lastClipboardActionWasCut = false ;
25
26
26
27
private static bool IsComposite ( SerializedProperty property ) => property . FindPropertyRelative ( "m_Flags" ) . intValue == ( int ) InputBinding . Flags . Composite ;
27
28
private static bool IsPartOfComposite ( SerializedProperty property ) => property . FindPropertyRelative ( "m_Flags" ) . intValue == ( int ) InputBinding . Flags . PartOfComposite ;
28
29
private static string PropertyName ( SerializedProperty property ) => property . FindPropertyRelative ( "m_Name" ) . stringValue ;
29
30
31
+ #region Cut
32
+
33
+ public static void CutActionMap ( InputActionsEditorState state )
34
+ {
35
+ CopyActionMap ( state ) ;
36
+ s_lastClipboardActionWasCut = true ;
37
+ }
38
+
39
+ public static void Cut ( InputActionsEditorState state )
40
+ {
41
+ Copy ( state ) ;
42
+ s_lastClipboardActionWasCut = true ;
43
+ }
44
+
45
+ #endregion
46
+
30
47
#region Copy
31
48
32
49
public static void CopyActionMap ( InputActionsEditorState state )
@@ -54,6 +71,7 @@ private static void CopySelectedTreeViewItemsToClipboard(List<SerializedProperty
54
71
var copyBuffer = new StringBuilder ( ) ;
55
72
CopyItems ( items , copyBuffer , type , actionMap ) ;
56
73
EditorGUIUtility . systemCopyBuffer = copyBuffer . ToString ( ) ;
74
+ s_lastClipboardActionWasCut = false ;
57
75
}
58
76
59
77
private static void CopyItems ( List < SerializedProperty > items , StringBuilder buffer , Type type , SerializedProperty actionMap )
@@ -152,6 +170,11 @@ public static SerializedProperty PasteActionMapsFromClipboard(InputActionsEditor
152
170
s_State = state ;
153
171
var actionMapArray = state . serializedObject . FindProperty ( nameof ( InputActionAsset . m_ActionMaps ) ) ;
154
172
PasteData ( EditorGUIUtility . systemCopyBuffer , new [ ] { state . selectedActionMapIndex } , actionMapArray ) ;
173
+
174
+ // Don't want to be able to paste repeatedly after a cut - ISX-1821
175
+ if ( s_lastAddedElement != null && s_lastClipboardActionWasCut )
176
+ EditorGUIUtility . systemCopyBuffer = string . Empty ;
177
+
155
178
return s_lastAddedElement ;
156
179
}
157
180
@@ -164,6 +187,11 @@ public static SerializedProperty PasteActionsOrBindingsFromClipboard(InputAction
164
187
PasteActionsFromClipboard ( state , addLast ) ;
165
188
if ( typeOfCopiedData == typeof ( InputBinding ) )
166
189
PasteBindingsFromClipboard ( state ) ;
190
+
191
+ // Don't want to be able to paste repeatedly after a cut - ISX-1821
192
+ if ( s_lastAddedElement != null && s_lastClipboardActionWasCut )
193
+ EditorGUIUtility . systemCopyBuffer = string . Empty ;
194
+
167
195
return s_lastAddedElement ;
168
196
}
169
197
0 commit comments