首先在蓝图并没有找到此功能,于是准备通过C++写一个然后蓝图去调用,具体操作方法如下:
在头文件中创建一个函数:
public:
//在指定路径创建文件夹
UFUNCTION(BlueprintCallable, Category = "File Management")
static bool CreateFolder(FString FolderPath);
在源文件中进行实现:
bool UBP_BlueprintFunctionLibrary::CreateFolder(FString FolderPath)
{
//获取当前平台的文件管理器实例,将其引用赋值给PlatformFile。
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
//判断指定路径文件夹是否存在
if (!PlatformFile.DirectoryExists(*FolderPath))
{
//如果文件夹不存在,创建一个
return PlatformFile.CreateDirectoryTree(*FolderPath);
}
return true; // 文件夹已存在
}
此时编译代码后打开需要调用此功能的蓝图,进行调用。
输入路径后进行运行
此时创建成功。