Skip to content

Instantly share code, notes, and snippets.

@bohdon
Last active August 30, 2022 03:57
Show Gist options
  • Save bohdon/92d86724b91ec0791631453c3496e5cf to your computer and use it in GitHub Desktop.
Save bohdon/92d86724b91ec0791631453c3496e5cf to your computer and use it in GitHub Desktop.
read a config value in a UE4 ModuleRules
/// <summary>
/// Get a value from a config file for the project of the current target
/// </summary>
/// <returns>true if a value was found for the given section and key</returns>
bool TryGetConfigValue(ConfigHierarchyType ConfigType, string SectionName, string KeyName, out string Value)
{
ConfigHierarchy Config = ConfigCache.ReadHierarchy(ConfigType, DirectoryReference.FromFile(Target.ProjectFile), Target.Platform);
if (Config != null)
{
ConfigHierarchySection Section = Config.FindSection(SectionName);
if (Section != null)
{
return Section.TryGetValue(KeyName, out Value);
}
}
Value = null;
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment