In my project I’ve created a custom GameUserSettings class and defined some Enums, and variables that use those enums. This is what it looks like:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameUserSettings.h"
#include "BoozeGameUserSettings.generated.h"
UENUM(BlueprintType)
enum class EBoozeUserSetting3Way : uint8 {
Disabled UMETA(DisplayName = "Disabled"),
Reduced UMETA(DisplayName = "Reduced"),
Full UMETA(DisplayName = "Full"),
};
UENUM(BlueprintType)
enum class EBoozeLanguageSetting : uint8 {
English UMETA(DisplayName = "English"),
};
UENUM(BlueprintType)
enum class EBoozeControllerTypes : uint8 {
X360 UMETA(DisplayName = "X360"),
XSERIESX UMETA(DisplayName = "XSERIESX"),
STEAMDECK UMETA(DisplayName = "STEAMDECK"),
PS5 UMETA(DisplayName = "PS5")
};
/**
*
*/
UCLASS()
class UBoozeGameUserSettings : public UGameUserSettings
{
GENERATED_UCLASS_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "BoozeGameUserSettings|Gameplay")
void ApplyBoozeGameplaySettings();
UFUNCTION(BlueprintCallable)
static UBoozeGameUserSettings* GetBoozeGameUserSettings();
UPROPERTY(Config, BlueprintReadWrite, Category = "BoozeGameUserSettings|Gameplay")
EBoozeUserSetting3Way HintIcons;
UPROPERTY(Config, BlueprintReadWrite, Category = "BoozeGameUserSettings|Gameplay")
EBoozeUserSetting3Way CameraShake;
UPROPERTY(Config, BlueprintReadWrite, Category = "BoozeGameUserSettings|Gameplay")
bool bAlwaysUseHoldQTE;
UPROPERTY(Config, BlueprintReadWrite, Category = "BoozeGameUserSettings|Gameplay")
EBoozeLanguageSetting Language;
};
(Yes, I’m being lazy and not using get/set functions for these - I’m just testing at the moment)
When I set any of these variables from Blueprints, they correctly save in GameUserSettings.ini, and reading them for the rest of the session is fine.
[/Script/BoozeGame.BoozeGameUserSettings]
HintIcons=Reduced
CameraShake=Full
bAlwaysUseHoldQTE=False
Language=English
But in a new session where the values are read from the .ini, the enum values are not read correctly and instead read as the first index (i.e. HintIcons reads as ‘Disabled’, rather than ‘Reduced’). Other settings like bAlwaysUseHoldQTE are correct, so I know that it is able to save and read from the file etc.
I’m not sure what could be wrong here - would appreciate any ideas.