1.新建UE C++项目,新建蓝图函数库的C++类。
2.在头文件.h中添加以下代码,将函数暴露给蓝图
public:
UFUNCTION(BlueprintCallable, Category = "OpenAndcReadFile")
static FString OpenWindowsFile(); //打开Windows文件夹窗口
UFUNCTION(BlueprintCallable, Category = "OpenAndcReadFile")
static FString ReadFile(FString TxtPath); //读入txt/json文件
UFUNCTION(BlueprintCallable, Category = "OpenAndcReadFile")
static bool WriteFile(FStirng Content,FString TxtPath); //写入txt/json文件
3.在cpp文件中添加实现代码
添加以下头文件引用
#include "Runtime\Core\Public\Misc\FileHelper.h"
#include "Runtime\Core\Public\Misc\Paths.h"
#include "Developer\DesktopPlatform\Public\IDesktopPlatform.h"
#include "Developer\DesktopPlatform\Pub