Dr_Jerm
(Dr_Jerm)
September 8, 2016, 11:34pm
1
Hey all. Just wondering how to make a config variable that is a boolean be correctly read in-game. I’ve successfully read strings and number from the config file (DefaultEngine.ini), however I’m struggling with a bool. So far I’ve tried:
[/Game/MyBlueprintClass.MyBlueprintClass_C]
variable=True
variable=true
variable=1
None with any luck.
mdonge
(mdonge)
September 9, 2016, 12:30pm
2
in c++, you can use GConfig->GetBool(…) and GConfig->SetBool(…)
I don’t have the real syntax this time, but it’s how I get bool var from config files
Dr_Jerm
(Dr_Jerm)
September 16, 2016, 10:13pm
3
Accessing the configs through C++ ended up being the easiest method. My implementation looked something like:
void UConfigLibrary::ReadConfigBoolValue(const FString FileNameWithPath, const FString VariableName, bool &value) {
value = false;
if (!GConfig) return;
const TCHAR* path = *FileNameWithPath;
const TCHAR* name = *VariableName;
bool ValueReceived = false;
GConfig->GetBool(
path,
name,
ValueReceived,
GEngineIni //Reading from DefaultEngine.ini or Engine.ini
);
value = ValueReceived;
return;
}
and the config looking like:
[lanConfig]
bEnabled=False
bIsServer=False
server="192.168.137.250"
1 Like