diff --git a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs
index cfc11d5a5..a0ee8d3dc 100644
--- a/Source/Editor/CustomEditors/Editors/CollectionEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/CollectionEditor.cs
@@ -70,7 +70,9 @@ namespace FlaxEditor.CustomEditors.Editors
menu.ItemsContainer.RemoveChildren();
menu.AddButton("Copy", linkedEditor.Copy);
- var b = menu.AddButton("Paste", linkedEditor.Paste);
+ var b = menu.AddButton("Duplicate", () => Editor.Duplicate(Index));
+ b.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
+ b = menu.AddButton("Paste", linkedEditor.Paste);
b.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
menu.AddSeparator();
@@ -404,8 +406,10 @@ namespace FlaxEditor.CustomEditors.Editors
var menu = new ContextMenu();
menu.AddButton("Copy", linkedEditor.Copy);
+ var b = menu.AddButton("Duplicate", () => Editor.Duplicate(Index));
+ b.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
var paste = menu.AddButton("Paste", linkedEditor.Paste);
- paste.Enabled = linkedEditor.CanPaste;
+ paste.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
if (_canReorder)
{
@@ -741,6 +745,34 @@ namespace FlaxEditor.CustomEditors.Editors
cloned[srcIndex] = tmp;
SetValue(cloned);
}
+
+ ///
+ /// Duplicates the list item.
+ ///
+ /// The index to duplicate.
+ public void Duplicate(int index)
+ {
+ if (IsSetBlocked)
+ return;
+
+ var count = Count;
+ var newValues = Allocate(count + 1);
+ var oldValues = (IList)Values[0];
+
+ for (int i = 0; i <= index; i++)
+ {
+ newValues[i] = oldValues[i];
+ }
+
+ newValues[index + 1] = Utilities.Utils.CloneValue(oldValues[index]);
+
+ for (int i = index + 1; i < count; i++)
+ {
+ newValues[i + 1] = oldValues[i];
+ }
+
+ SetValue(newValues);
+ }
///
/// Shifts the specified item at the given index and moves it through the list to the other item. It supports undo.