MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Duplicate

Method Duplicate

Source/Editor/Windows/ContentWindow.cs:874–898  ·  view source on GitHub ↗

Clones the specified item. The item.

(ContentItem item)

Source from the content-addressed store, hash-verified

872 /// </summary>
873 /// <param name="item">The item.</param>
874 public void Duplicate(ContentItem item)
875 {
876 // Skip null
877 if (item == null)
878 return;
879
880 // TODO: don't allow to duplicate items without ParentFolder - like root items (Content, Source, Engine and Editor dirs)
881
882 // Clone item
883 var targetPath = GetClonedAssetPath(item);
884 Editor.ContentDatabase.Copy(item, targetPath);
885
886 // Refresh this folder now and try to find duplicated item
887 Editor.ContentDatabase.RefreshFolder(item.ParentFolder, true);
888 RefreshView();
889 RefreshTreeItems();
890 var targetItem = item.ParentFolder.FindChild(targetPath);
891
892 // Start renaming it
893 if (targetItem != null)
894 {
895 Select(targetItem);
896 Rename(targetItem);
897 }
898 }
899
900 /// <summary>
901 /// Duplicates the specified items.

Callers 1

GameWindowMethod · 0.45

Calls 3

RefreshFolderMethod · 0.80
FindChildMethod · 0.80
CopyMethod · 0.45

Tested by

no test coverage detected