I’m trying to get a value from a struct in an array that is part of the project settings.
I know you can get a string like this:
FString UBpFuncs::GetGameName()
{
FString projName;
GConfig->GetString(TEXT("/Script/EngineSettings.GeneralProjectSettings"), TEXT("ProjectName"), projName, GGameIni);
return projName;
}
But how would you get a value out of an array?
This is the .h file where I make the settings:
UCLASS(config=Game, DefaultConfig, DisplayName="Game Settings")
class SIBERIA_API USiberiaDeveloperSettings : public UDeveloperSettings
{
GENERATED_BODY()
public:
USiberiaDeveloperSettings(const FObjectInitializer &ObjectInitializer);
UPROPERTY(config, BlueprintReadOnly, EditAnywhere, Category="AI")
TArray<FDifficulty> Difficulties;
static const USiberiaDeveloperSettings* Get();
};
And this is the FDifficulty
struct:
USTRUCT(BlueprintType)
struct FDifficulty
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FName DifficultyName;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
float DamageMult = 1.f;
FDifficulty() {};
FDifficulty(FName DifName, float DmgMult):
DifficultyName(std::move(DifName)),
DamageMult(std::move(DmgMult))
{};
};
I want to get either the FDifficulty of a specific index, or one of the values within that FDifficulty (like the DifficultyName)
And this is from the “DefaultGame.ini” file in the “Config” folder
[/Script/Siberia.SiberiaDeveloperSettings]
+Difficulties=(DifficultyName="Easy",DamageMult=0.500000)
+Difficulties=(DifficultyName="Normal",DamageMult=1.000000)
+Difficulties=(DifficultyName="Hard",DamageMult=1.500000)
Let me know if you need any other info.
Thanks.