From 47b375b1af93f77978a2d58244ff603fc007e98d Mon Sep 17 00:00:00 2001 From: emerycp Date: Sat, 22 Jul 2023 00:25:30 -0400 Subject: [PATCH] NK-114 - Creating Prefab without extension doesn't add .prefab --- Editor/src/Windows/EditorInterface.cpp | 14 ++++++++++++-- Editor/src/Windows/FileSystemUI.cpp | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 7c993e65..2c2d8f25 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -402,8 +402,18 @@ namespace Nuake { { Ref newPrefab = Prefab::CreatePrefabFromEntity(Selection.Entity); std::string savePath = FileDialog::SaveFile("*.prefab"); - newPrefab->SaveAs(savePath); - Selection.Entity.AddComponent().PrefabInstance = newPrefab; + if (!String::EndsWith(savePath, ".prefab")) + { + savePath += ".prefab"; + } + + if (!savePath.empty()) + { + newPrefab->SaveAs(savePath); + Selection.Entity.AddComponent().PrefabInstance = newPrefab; + FileSystem::Scan(); + FileSystemUI::m_CurrentDirectory = FileSystem::RootDirectory; + } } ImGui::EndPopup(); } diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 55d690ef..181ddf97 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -247,7 +247,7 @@ namespace Nuake path += ".material"; } - if (path != "") + if (!path.empty()) { Ref material = CreateRef(); material->IsEmbedded = false;