UE4中 路径引用 书写问题
目的: 项目打包之后, 一般需要通过外部的配置文件来更改项目中的某些变量, 这时候 配置文件的 设置路径就有了重要的意义。
本文从 ini 格式的文件进行入手,进行实际的测试效果。
测试前提: UE4 4.18 配置文件命名: test.ini
配置文件内容:
[IpSetting]
IpAdress=192.168.0.53
IpPort=8090
一,打包之后的路径定义
1,InstallDir/WindowsNoEditor/
含义: 直接在打包之后 WindowsNoEditor 目录之下
FString ThePath = FPaths::ConvertRelativePathToFull(FPaths::RootDir()) + TEXT(“test.ini”);;
2,InstallDir/WindowsNoEditor/GameName
FString ThePath = FPaths::ConvertRelativePathToFull(FPaths::GameDir()) + TEXT(“test.ini”);;
下面的未测试,以上两个对我来说已经足够使用了。
3, InstallDir/WindowsNoEditor/GameName/Content
//InstallDir/WindowsNoEditor/GameName/Content
FString ThePath = FPaths::ConvertRelativePathToFull(FPaths::GameContentDir());
4,InstallDir/WindowsNoEditor/GameName/Saved
//InstallDir/WindowsNoEditor/GameName/Saved
FString ThePath = FPaths::ConvertRelativePathToFull(FPaths::GameSavedDir());
5,InstallDir/WindowsNoEditor/GameName/Saved/Logs
//InstallDir/WindowsNoEditor/GameName/Saved/Logs
FString ThePath = FPaths::ConvertRelativePathToFull(FPaths::GameLogDir());
6,InstallDir/WindowsNoEditor/GameName/Plugins(新增)
FString ThePath = FPaths::ConvertRelativePathToFull(FPaths::ProjectPluginsDir());
二,未打包时的路径
FString ContentPath = FPaths::ConvertRelativePathToFull(FPaths::GameContentDir()) + TEXT(“Configs/test.ini”); //content 目录下的文件夹目录
比较邪门的是,使用未打包的路径,每次修改完之后,直接在editor 模式下运行, 修改的数据并不能直接反应在程序里面。还需要重新generate 一下才行, 为此就不再对此进行多余的操作了。