Description

proposed fix seems ok to me: 

UEnhancedInputUserSettings* UEnhancedInputUserSettings::LoadOrCreateSettings(ULocalPlayer* LocalPlayer)
{
    UEnhancedInputUserSettings* Settings = nullptr;

    if (!LocalPlayer)
    {
       UE_LOG(LogEnhancedInput, Log, TEXT("Unable to determine an owning Local Player for the given Enhanced Player Input object"));
       return nullptr;
    }
    
    // If the save game exists, load it.
    if (UGameplayStatics::DoesSaveGameExist(UE::EnhancedInput::SETTINGS_SLOT_NAME, LocalPlayer->GetLocalPlayerIndex()))
    {
       USaveGame* Slot = UGameplayStatics::LoadGameFromSlot(UE::EnhancedInput::SETTINGS_SLOT_NAME, LocalPlayer->GetLocalPlayerIndex());
       Settings = Cast<UEnhancedInputUserSettings>(Slot);
    }

    // If there is no settings save game object, then we can create on
    // based on the class type set in the developer settings
    // <#Engine_Mod>
    //
    // Previous code:
    //     if (Settings == nullptr)
    //  {
    //     const UEnhancedInputDeveloperSettings* DevSettings = GetDefault<UEnhancedInputDeveloperSettings>();
    //     UClass* SettingsClass = DevSettings->UserSettingsClass ? DevSettings->UserSettingsClass.Get() : UEnhancedInputDeveloperSettings::StaticClass();
    //     
    //     Settings = Cast<UEnhancedInputUserSettings>(UGameplayStatics::CreateSaveGameObject(SettingsClass));
    //  }
    const UEnhancedInputDeveloperSettings* DevSettings = GetDefault<UEnhancedInputDeveloperSettings>();
    UClass* SettingsClass = DevSettings->UserSettingsClass ? DevSettings->UserSettingsClass.Get() : UEnhancedInputDeveloperSettings::StaticClass();
    if (Settings == nullptr || !Settings->IsA(SettingsClass))
    {
       // </#Engine_Mod>
       Settings = Cast<UEnhancedInputUserSettings>(UGameplayStatics::CreateSaveGameObject(SettingsClass));
    }

    if (ensure(Settings))
    {
       Settings->Initialize(LocalPlayer);
        Settings->ApplySettings(); 
    }

    return Settings;
} 
Steps to Reproduce
  1. Save some key profile settings
  2. Change the default enhanced input user settings class to be something custom in the developer settings
  3. Attempt to load the existing settiings

Result: it fails to load the settings because the class has changed

expected: We gracefully handle the changing of settings classes without forcing people to delete the settings manually out of the saved folder

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-216386 in the post.

0
Login to Vote

Fixed
ComponentUE - Gameplay - Input
Affects Versions5.3
Target Fix5.5
Fix Commit34286832
CreatedJun 3, 2024
ResolvedJun 11, 2024
UpdatedJul 3, 2024
View Jira Issue