UE4C++调用windows系统文件夹路径选取窗口
虚幻中是可以创建不同系统的桌面实例的,并且提供不同的函数接口进行不同操作
OpendDirectoryDialog函数进行文件夹路径的选择

第一步:创建一个桌面实例,根据参数类型给参数
参数解读:ParentWindowHandle 父类窗口类型
DialogTitle 对话框的标题
DefaultPath 打开对话框的默认路径
OutFolderName 用户自定义选择的文件路径名字
创建一个 返回FString类型的函数

通过FPaths:ConvertRelativePathToFull(FPaths::ProjectDir)获得项目的路径
OpenFileDialog根据类型选择文件资源
/**
* Opens the "open file" dialog for the platform
*
* @param ParentWindowHandle The native handle to the parent window for this dialog
* @param DialogTitle The text for the title of the dialog window
* @param DefaultPath The path where the file dialog will open initially
* @param DefaultFile The file that the dialog will select initially
* @param Flags Details about the dialog. See EFileDialogFlags.
* @param FileTypes The type filters to show in the dialog. This string should be a "|" delimited list of (Description|Extensionlist) pairs. Extensionlists are ";" delimited.
* @param OutFilenames The filenames that were selected in the dialog
* @param OutFilterIndex The type that was selected in the dialog
* @return true if files were successfully selected
*/
virtual bool OpenFileDialog(const void* ParentWindowHandle, const FString& DialogTitle, const FString& DefaultPath, const FString& DefaultFile, const FString& FileTypes, uint32 Flags, TArray<FString>& OutFilenames, int32& outFilterIndex ) = 0;

浙公网安备 33010602011771号