From e3169c2c04f36270527a41d9e108dceabb36a346 Mon Sep 17 00:00:00 2001 From: Andrey Boronnikov Date: Tue, 11 Mar 2025 11:14:25 +0300 Subject: [PATCH 1/3] Update FormerlySerializedTypeAttribute.cs Fix Error on build in Unity 6 #14 --- .../Package/Scripts/FormerlySerializedTypeAttribute.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 +} From a33c88d63223b2301a5bfc93dbd5e72125c03522 Mon Sep 17 00:00:00 2001 From: Andrey Boronnikov Date: Tue, 5 May 2026 11:27:38 +0300 Subject: [PATCH 2/3] Add copy, paste, and cut actions for managed references --- .../Scripts/SRActions/CopyPropertySRAction.cs | 17 +++++++++++++ .../Scripts/SRActions/CutPropertySRAction.cs | 22 +++++++++++++++++ .../SRActions/PastePropertySRAction.cs | 24 +++++++++++++++++++ .../Scripts/SRActions/SRActionFactory.cs | 11 ++++++++- .../Editor/Scripts/SRActions/SRClipboard.cs | 9 +++++++ .../SearchTree/SRTypesSearchWindowProvider.cs | 17 ++++++++++++- 6 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CopyPropertySRAction.cs create mode 100644 SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CutPropertySRAction.cs create mode 100644 SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/PastePropertySRAction.cs create mode 100644 SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRClipboard.cs 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/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/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/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/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 +} From 47a48e28a7c948fdcbc8becd9a386751c04dc4d7 Mon Sep 17 00:00:00 2001 From: Andrey Boronnikov Date: Tue, 5 May 2026 11:35:57 +0300 Subject: [PATCH 3/3] Add Unity meta files for new SR actions --- .../Editor/Scripts/SRActions/CopyPropertySRAction.cs.meta | 3 +++ .../Editor/Scripts/SRActions/CutPropertySRAction.cs.meta | 3 +++ .../Editor/Scripts/SRActions/PastePropertySRAction.cs.meta | 3 +++ .../Package/Editor/Scripts/SRActions/SRClipboard.cs.meta | 3 +++ 4 files changed, 12 insertions(+) create mode 100644 SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CopyPropertySRAction.cs.meta create mode 100644 SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/CutPropertySRAction.cs.meta create mode 100644 SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/PastePropertySRAction.cs.meta create mode 100644 SerializeReferenceEditor/Assets/SREditor/Package/Editor/Scripts/SRActions/SRClipboard.cs.meta 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.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.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/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