diff --git a/Source/Editor/Editor.cpp b/Source/Editor/Editor.cpp index 58739917e..92c15f591 100644 --- a/Source/Editor/Editor.cpp +++ b/Source/Editor/Editor.cpp @@ -526,6 +526,17 @@ int32 Editor::LoadProduct() return 12; } + // Get the last opened project path + String localCachePath; + FileSystem::GetSpecialFolderPath(SpecialFolder::AppData, localCachePath); + String editorConfigPath = localCachePath / TEXT("Flax"); + String lastProjectSettingPath = editorConfigPath / TEXT("LastProject.txt"); + if (!FileSystem::DirectoryExists(editorConfigPath)) + FileSystem::CreateDirectory(editorConfigPath); + String lastProjectPath; + if (FileSystem::FileExists(lastProjectSettingPath)) + File::ReadAllText(lastProjectSettingPath, lastProjectPath); + // Missing project case if (projectPath.IsEmpty()) { @@ -541,7 +552,7 @@ int32 Editor::LoadProduct() Array files; if (FileSystem::ShowOpenFileDialog( nullptr, - StringView::Empty, + lastProjectPath, TEXT("Project files (*.flaxproj)\0*.flaxproj\0All files (*.*)\0*.*\0"), false, TEXT("Select project to open in Editor"), @@ -625,6 +636,10 @@ int32 Editor::LoadProduct() } } + // Update the last opened project path + if (lastProjectPath.Compare(Project->ProjectFolderPath) != 0) + File::WriteAllText(lastProjectSettingPath, Project->ProjectFolderPath, Encoding::UTF8); + return 0; }