I’m trying to get a windows environment variable in Unreal 4 (we work with multiple versions, from 4.9-4.14 - This example tested with 4.14).
I found this function: FGenericPlatformMisc::GetEnvironmentVariable
But as far as I can tell, it does not work.
I have anecdotal evidence that it doesn’t work for internal UE4 purposes either (My android environment vars are all defined properly, but Unreal says they don’t exist and can’t find them, even though they were set correctly).
Here’s my code (part of the constructor for an actor):
int32 valueLength = 512;
TCHAR* envVarValue = new TCHAR[valueLength];
FGenericPlatformMisc::GetEnvironmentVariable(TEXT("PF_TEST_TITLE_DATA_JSON"), envVarValue, valueLength);
if (envVarValue[0] != 0)
TEST_TITLE_DATA_LOC = envVarValue;
I’m running a project in-editor debugging with Visual Studio, envVarValue is always empty string after executing this code.