您的位置:首页 > 产品设计 > UI/UE

UE4 读取XML插件制作

2017-06-01 16:31 295 查看
1.创建插件



2.将插件的类型从默认的Develop改为Runtime,这是为了是之后能够生成.lib文件

3.在插件ReadXML.Build.cs里包含相关的模块”XmlParser”



4.在插件的头文件中添加相关的xml头文件



5.添加XML文件



6..h添加函数

public:
UFUNCTION(BlueprintCallable, Category ="MyPlugin")
static boolReadXML(FString& MaxFPS, FString& SetRes, FString&ScreenPercentage);
.cpp

bool UReadXMLBPLibrary::ReadXML(
FString& MaxFPS,
FString& SetRes,
FString& ScreenPercentage
)
{
//Plugin的所在路径下的XmlFiles文件中的Setting.xml文件
if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*(FPaths::GamePluginsDir() + L"XmlFiles\\Setting.xml")))
{
UE_LOG(LogTemp, Warning, TEXT("Find XML File!"));
FXmlFile*file = new FXmlFile(FPaths::GamePluginsDir() + L"XmlFiles\\Setting.xml");
FXmlNode*RootNode = file->GetRootNode();
FXmlNode*MaxFPSNode = RootNode->FindChildNode("MaxFPS");
MaxFPS = *MaxFPSNode->GetContent();

FXmlNode* SetresNode = RootNode->FindChildNode("Setres");
SetRes = *SetresNode->GetContent();

FXmlNode* ScreenPercentageNode = RootNode->FindChildNode("ScreenPercentage");
ScreenPercentage = *ScreenPercentageNode->GetContent();

return true;
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Cannot Find XML File"));
return false;
}
}
8.保存后退出重新从VS打开项目(这步很重要!!)下面就能调用了



转载地址:http://blog.csdn.net/Szu_IT_Man/article/details/52776448

可参考http://blog.csdn.net/zilisen/article/details/72954339
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: