Hi there. I have the following problem. I want users of my plugin to be able to change default structure values from the settings of the plugin. The problem is that I don’t actually understand how to do this. I found the article on this forum, but it didn’t help me.
Now my code looks like this:
The structure which should always have the correct default values of variables from the setting of the plugin:
USTRUCT(BlueprintType)
struct FMySettings
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, config)
float DelayBeforDisplaying;
UPROPERTY(EditAnywhere, BlueprintReadWrite, config)
bool bShowShadow;
};
The class which will represent the setting for a user:
UCLASS(BlueprintType, config = Game, defaultconfig)
class UCustomGameSettings : public UObject
{
GENERATED_BODY()
public:
UCustomGameSettings(const FObjectInitializer& ObjectInitializer);
UPROPERTY(config = Game, EditAnywhere, Category = Custom, DisplayName = "Default MBS Settings")
FMySettings SettingsMBS;
};
Settings registration in the system:
if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings"))
{
ISettingsContainerPtr SettingsContainer = SettingsModule->GetContainer("Project");
SettingsContainer->DescribeCategory("CustomSettings",
FText::FromString("CustomSettings"),
FText::FromString("Game configuration for the CustomSettings game module"));
ISettingsSectionPtr SettingsSection = SettingsModule->RegisterSettings("Project", "CustomSettings", "General",
FText::FromString("General"),
FText::FromString("Base configuration for our game module"),
GetMutableDefault<UCustomGameSettings>()
);
if (SettingsSection.IsValid())
{
SettingsSection->OnModified().BindRaw(this, &FMySettingsPluginModule::HandleSettingsSaved);
}
}
Settings display, change and save to DefaultGame.ini:
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_143618_1532927769242_618”,“title”:“Changed-properties-from-Settings.png”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
Ini file review. The settings were entered correctly:
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_143619_1532927967829_139”,“title”:“Saved-properties.png”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
Variable creation in blueprint. Default values aren’t the same as in the settings:
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_143620_1532928499130_572”,“title”:“Show-wrong-default-properties.png”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
Also, I’d like the correct default values of my structure to be displayed in Inputs or Outputs:
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_143621_1532928715932_45”,“title”:“Input-func-properties.png”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
Or to set settings in the function via Make:
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_143622_1532928836306_817”,“title”:“Input-func-properties-via-Make.png”}[/ATTACH]
https://forums.unrealengine.com/core/image/gif;base64
I’d be happy to receive any help or ideas. Thanks.