diff --git a/Source/Editor/Content/Proxy/PrefabProxy.cs b/Source/Editor/Content/Proxy/PrefabProxy.cs index c0c4e5c88..d2971f296 100644 --- a/Source/Editor/Content/Proxy/PrefabProxy.cs +++ b/Source/Editor/Content/Proxy/PrefabProxy.cs @@ -73,6 +73,16 @@ namespace FlaxEditor.Content return targetLocation.CanHaveAssets; } + /// + public override bool CanReimport(ContentItem item) + { + if (item is not PrefabItem prefabItem) + return base.CanReimport(item); + + var prefab = FlaxEngine.Content.Load(prefabItem.ID); + return prefab.GetDefaultInstance().GetScript() != null; + } + /// public override void Create(string outputPath, object arg) { diff --git a/Source/Editor/Windows/ContentWindow.ContextMenu.cs b/Source/Editor/Windows/ContentWindow.ContextMenu.cs index 4b21a2e6a..ffac4c822 100644 --- a/Source/Editor/Windows/ContentWindow.ContextMenu.cs +++ b/Source/Editor/Windows/ContentWindow.ContextMenu.cs @@ -311,6 +311,23 @@ namespace FlaxEditor.Windows { if (selection[i] is BinaryAssetItem binaryAssetItem) Editor.ContentImporting.Reimport(binaryAssetItem); + else if (selection[i] is PrefabItem prefabItem) + { + var prefab = FlaxEngine.Content.Load(prefabItem.ID); + var modelPrefab = prefab.GetDefaultInstance().GetScript(); + if (!modelPrefab) + continue; + var importPath = modelPrefab.ImportPath; + var editor = Editor.Instance; + if (editor.ContentImporting.GetReimportPath("Model Prefab", ref importPath)) + continue; + var folder = editor.ContentDatabase.Find(Path.GetDirectoryName(prefab.Path)) as ContentFolder; + if (folder == null) + continue; + var importOptions = modelPrefab.ImportOptions; + importOptions.Type = FlaxEngine.Tools.ModelTool.ModelType.Prefab; + editor.ContentImporting.Import(importPath, folder, true, importOptions); + } } }