diff --git a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CopyPropertySRAction.cs b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CopyPropertySRAction.cs new file mode 100644 index 0000000..c6b7440 --- /dev/null +++ b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CopyPropertySRAction.cs @@ -0,0 +1,17 @@ +using UnityEditor; + +namespace SerializeReferenceEditor.Editor.SRActions +{ + public class CopyPropertySRAction : BaseSRAction + { + public CopyPropertySRAction(SerializedProperty currentProperty, SerializedProperty parentProperty) + : base(currentProperty, parentProperty) + { + } + + protected override void DoApply() + { + SRClipboard.ManagedReferenceValue = Property.managedReferenceValue; + } + } +} diff --git a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CopyPropertySRAction.cs.meta b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CopyPropertySRAction.cs.meta new file mode 100644 index 0000000..63e587b --- /dev/null +++ b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CopyPropertySRAction.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1ede87433ef3403e853336b2c7b26d11 +timeCreated: 1770000000 diff --git a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CutPropertySRAction.cs b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CutPropertySRAction.cs new file mode 100644 index 0000000..f1a9128 --- /dev/null +++ b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CutPropertySRAction.cs @@ -0,0 +1,22 @@ +using UnityEditor; + +namespace SerializeReferenceEditor.Editor.SRActions +{ + public class CutPropertySRAction : BaseSRAction + { + public CutPropertySRAction(SerializedProperty currentProperty, SerializedProperty parentProperty) + : base(currentProperty, parentProperty) + { + } + + protected override void DoApply() + { + Undo.RegisterCompleteObjectUndo(Property.serializedObject.targetObject, "Cut element"); + Undo.FlushUndoRecordObjects(); + + SRClipboard.ManagedReferenceValue = Property.managedReferenceValue; + Property.managedReferenceValue = null; + Property.serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CutPropertySRAction.cs.meta b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CutPropertySRAction.cs.meta new file mode 100644 index 0000000..96807b7 --- /dev/null +++ b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CutPropertySRAction.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e9b5a5ac9c94408cb095108828def7b0 +timeCreated: 1770000001 diff --git a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/PastePropertySRAction.cs b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/PastePropertySRAction.cs new file mode 100644 index 0000000..6eb36a1 --- /dev/null +++ b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/PastePropertySRAction.cs @@ -0,0 +1,24 @@ +using UnityEditor; + +namespace SerializeReferenceEditor.Editor.SRActions +{ + public class PastePropertySRAction : BaseSRAction + { + public PastePropertySRAction(SerializedProperty currentProperty, SerializedProperty parentProperty) + : base(currentProperty, parentProperty) + { + } + + protected override void DoApply() + { + if (!SRClipboard.HasValue) + return; + + Undo.RegisterCompleteObjectUndo(Property.serializedObject.targetObject, "Paste element"); + Undo.FlushUndoRecordObjects(); + + Property.managedReferenceValue = SRClipboard.ManagedReferenceValue; + Property.serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/PastePropertySRAction.cs.meta b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/PastePropertySRAction.cs.meta new file mode 100644 index 0000000..60c47d1 --- /dev/null +++ b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/PastePropertySRAction.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: da1bd126d4434873bef15b20176d8e6e +timeCreated: 1770000002 diff --git a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRActionFactory.cs b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRActionFactory.cs index cda35fe..f40bed1 100644 --- a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRActionFactory.cs +++ b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRActionFactory.cs @@ -23,5 +23,14 @@ public InstanceClassSRAction InstantiateBuild(string type) public ErasePropertySRAction EraseBuild() => new ErasePropertySRAction(_currentProperty, _parentProperty); + + public CopyPropertySRAction CopyBuild() + => new CopyPropertySRAction(_currentProperty, _parentProperty); + + public PastePropertySRAction PasteBuild() + => new PastePropertySRAction(_currentProperty, _parentProperty); + + public CutPropertySRAction CutBuild() + => new CutPropertySRAction(_currentProperty, _parentProperty); } -} \ No newline at end of file +} diff --git a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRClipboard.cs b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRClipboard.cs new file mode 100644 index 0000000..9f7f683 --- /dev/null +++ b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRClipboard.cs @@ -0,0 +1,9 @@ +namespace SerializeReferenceEditor.Editor.SRActions +{ + public static class SRClipboard + { + public static object ManagedReferenceValue { get; set; } + + public static bool HasValue => ManagedReferenceValue != null; + } +} diff --git a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRClipboard.cs.meta b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRClipboard.cs.meta new file mode 100644 index 0000000..e51fb11 --- /dev/null +++ b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRClipboard.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8da5447306724996b06d0b65e16b1d45 +timeCreated: 1770000003 diff --git a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SearchTree/SRTypesSearchWindowProvider.cs b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SearchTree/SRTypesSearchWindowProvider.cs index b85043e..1093d51 100644 --- a/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SearchTree/SRTypesSearchWindowProvider.cs +++ b/SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SearchTree/SRTypesSearchWindowProvider.cs @@ -40,10 +40,25 @@ private static List GenerateSearchTreeEntries( userData = srActionFactory.EraseBuild(), level = 1 }, + new(new GUIContent("Copy")) + { + userData = srActionFactory.CopyBuild(), + level = 1 + }, + new(new GUIContent("Paste")) + { + userData = srActionFactory.PasteBuild(), + level = 1 + }, + new(new GUIContent("Cut")) + { + userData = srActionFactory.CutBuild(), + level = 1 + }, }; list.AddRange(srTypeTreeFactory.MakeTypesTree(srActionFactory)); return list; } } -} \ No newline at end of file +} diff --git a/SerializeReferenceEditor/Assets/SREditor/Package/Scripts/FormerlySerializedTypeAttribute.cs b/SerializeReferenceEditor/Assets/SREditor/Package/Scripts/FormerlySerializedTypeAttribute.cs index 41ae1d7..00269eb 100644 --- a/SerializeReferenceEditor/Assets/SREditor/Package/Scripts/FormerlySerializedTypeAttribute.cs +++ b/SerializeReferenceEditor/Assets/SREditor/Package/Scripts/FormerlySerializedTypeAttribute.cs @@ -1,6 +1,8 @@ using System; using System.Linq; +#if UNITY_EDITOR using SerializeReferenceEditor.Services; +#endif namespace SerializeReferenceEditor { @@ -87,4 +89,4 @@ public FormerlySerializedTypeAttribute(string oldTypeFullName) } #endif } -} \ No newline at end of file +}