From bca5e908f1b85da6ec41fb3e2d5bf283ff126326 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 27 May 2023 00:40:52 +0300 Subject: [PATCH] Copy content files using Content Database instead of Content Importing Fixes an issue where copying asset files does not change the asset ID, causing the copied assets to remain linked to the original files. --- Source/Editor/Windows/ContentWindow.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs index c9c1a8d21..c2b56466d 100644 --- a/Source/Editor/Windows/ContentWindow.cs +++ b/Source/Editor/Windows/ContentWindow.cs @@ -611,7 +611,20 @@ namespace FlaxEditor.Windows /// The files paths to import. public void Paste(string[] files) { - Editor.ContentImporting.Import(files, CurrentViewFolder); + List importFiles = new List(); + foreach (var sourcePath in files) + { + var item = Editor.ContentDatabase.Find(sourcePath); + if (item != null) + { + string targetPath = Path.Combine(CurrentViewFolder.Path, item.FileName); + Editor.ContentDatabase.Copy(item, targetPath); + } + else + importFiles.Add(sourcePath); + } + + Editor.ContentImporting.Import(importFiles, CurrentViewFolder); } ///