Hello,
I am building a game for Win64 in 4.27. When playing the game the user can take highres screenshots. Normally these screenshots are saved in a pre-determined folder. I want to give the player the possibility to change this folder using FDesktopPlatformModule::OpenDirectoryDialog(). When playing in the editor (or as stand alone) everything works as expected. However, after packaging my game for shipping and run the game outside unreal, the game crashes at the moment it should open the OpenDirectoryDialog.
Include file
UFUNCTION(BlueprintCallable, Category = "Files|Dirs")
static void OpenDirDialog(const FString& DialogTitle, const FString& DefaultPath, FString& OutDirNames);
code
void UPBFunctionLibrary::OpenDirDialog(const FString& DialogTitle, const FString& DefaultPath, FString& OutDirNames)
{
if (GEngine)
{
if (GEngine->GameViewport)
{
void* ParentWindowHandle = GEngine->GameViewport->GetWindow()->GetNativeWindow()->GetOSWindowHandle();
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (DesktopPlatform)
{
//Opening the file picker!
uint32 SelectionFlag = 0; //A value of 0 represents single file selection while a value of 1 represents multiple file selection
DesktopPlatform->OpenDirectoryDialog(ParentWindowHandle, DialogTitle, DefaultPath, OutDirNames);
}
}
}
}
Does OpenDirectoryDialog only work in a non-shipping build?
Any help is appreciated.
Thanks,
Richard
Bumping because i am facing the same issue.
1 Like
I have the same problem. DesktopPlatform is a developper tool. So, in shipping built, there is no developper tool.
Did you find a way to work with DesktopPlatform in your shipping built?
I stopped trying because AFAIK including developer tools in your shipping build is against Unreal Engine’s EULA.
I guess you could look at c++ cross-platform library and include them in a plugin or if you only target windows use this plugin :
that crash is expected unfortunately. IDesktopPlatform lives in a Developer module, so in a shipping build the whole thing is stripped out and the call dies right there. works in PIE and standalone, dies packaged, that pattern is the classic sign.
the fix is to not go through DesktopPlatform at all in a shipped game. you want a Runtime module that calls the OS folder dialog directly with the game viewport as parent window, then marshals the result back to the game thread. that is also how you avoid the dialog hiding behind a borderless fullscreen window.
if you dont want to write that layer yourself, Async Runtime File Dialog, a native file picker plugin for Unreal Engine 5, does exactly this for packaged Win64 builds. its Open Directory Picker node fires On Directory Selected or On Cancelled on the game thread, works in 5.0-5.8, no C++ needed: Async Runtime File Dialog — Native OS File Picker for Blueprints | Fab
for your screenshot flow, call the picker once, cache the folder string, and default all later saves there so players only pick once.