Add ModelPrefab to imported model prefab for reimporting functionality

This commit is contained in:
Wojtek Figat
2023-12-07 10:25:45 +01:00
parent 74b77bfa4c
commit cb92110976
9 changed files with 179 additions and 36 deletions

View File

@@ -126,29 +126,35 @@ namespace FlaxEditor.Modules
{
if (item != null && !item.GetImportPath(out string importPath))
{
// Check if input file is missing
if (!System.IO.File.Exists(importPath))
{
Editor.LogWarning(string.Format("Cannot reimport asset \'{0}\'. File \'{1}\' does not exist.", item.Path, importPath));
if (skipSettingsDialog)
return;
// Ask user to select new file location
var title = string.Format("Please find missing \'{0}\' file for asset \'{1}\'", importPath, item.ShortName);
if (FileSystem.ShowOpenFileDialog(Editor.Windows.MainWindow, null, "All files (*.*)\0*.*\0", false, title, out var files))
return;
if (files != null && files.Length > 0)
importPath = files[0];
// Validate file path again
if (!System.IO.File.Exists(importPath))
return;
}
if (GetReimportPath(item.ShortName, ref importPath, skipSettingsDialog))
return;
Import(importPath, item.Path, true, skipSettingsDialog, settings);
}
}
internal bool GetReimportPath(string contextName, ref string importPath, bool skipSettingsDialog = false)
{
// Check if input file is missing
if (!System.IO.File.Exists(importPath))
{
Editor.LogWarning(string.Format("Cannot reimport asset \'{0}\'. File \'{1}\' does not exist.", contextName, importPath));
if (skipSettingsDialog)
return true;
// Ask user to select new file location
var title = string.Format("Please find missing \'{0}\' file for asset \'{1}\'", importPath, contextName);
if (FileSystem.ShowOpenFileDialog(Editor.Windows.MainWindow, null, "All files (*.*)\0*.*\0", false, title, out var files))
return true;
if (files != null && files.Length > 0)
importPath = files[0];
// Validate file path again
if (!System.IO.File.Exists(importPath))
return true;
}
return false;
}
/// <summary>
/// Imports the specified files.
/// </summary>