#Instanced Structs in Config with Optional Modules

1 messages · Page 1 of 1 (latest)

ruby sleet
#

i am losing my mind with configs right now and i dont even really know how to breakdown the issue simply but im gonna try, i add code later but it really won't help much imo cause i know what the issue is:

I have an optional module thats only loaded when a dependant plugin is available.

The Problem: My config settings is setup in the primary module, but it has a field of settings that relies on largely varied data so im using instanced structs for it.

UPROPERTY(standard config and syntax...)
Ex: TArray<FInstancedStruct> Data 
//Actual structure is a TMap<SomeType,StructHere>

This works perfectly fine with any other struct from any other module EXCEPT my conditional module which add some new struct types.
These are unable to be found by the settings data when registered and thus always get set to none on reload. It does not matter if i load the module befoe or after registering my settings.

if (!LoadOptionalModule())
{...}

RegisterSettings();

Produces the same results regardless of load placement. Registration is the standard

{
    USettingsType* PluginSettings = GetMutableDefault<USettingsType>();

    SettingsModule->RegisterSettings("Project", "Plugins", "...NamesHere...",
        LOCTEXT("RuntimeSettingsName", "...NamesHere..."),
        LOCTEXT("RuntimeSettingsDescription", "...Description..."),
        PluginSettings
    );    
}

I have tried the following:

  1. Creating a child class of the settings in the module and registering that instead. This works but they underlying data of the parent USettingsType remains unchanged. This is problematic as my internal code can only reference the parent type without adding dependencies
  2. Using a child class to store the data on engine shutdown and then passing it back to the parent. Problem: I cannot get the config data to save between engine launches.
#

Notes: Its not ideal for me to create a new set of settings just for the optional module.

wraith thistle
#

Could be that your module shuts down, engine configs are resaved and the now invalid structs are cleared.

#

Not entirely sure how you've got FInstancedStruct in a TSet considering it doesn't have GetTypeHash AFAIK

#

Not really surprised that an optional module breaks that though, you can't do that with non-config UPROPERTY either

ruby sleet
# wraith thistle Could be that your module shuts down, engine configs are resaved and the now inv...

You're right , TSet was just an example cause i was running out of disc line count.

In the configs, the data gets saved and shows appropriately: if i had the struct it will show as /Script/StructModule.StructType()

But i get an issue on startup when i dont load the optional module before registration that says that it can't find that struct.
do you think maybe on shutdown its doing something similar?

floral flicker
#

hm I ran into such issues (BPs not InstancedStruct though, and no optional modules) if the loading order is not setup correctly (I do this via the uproject module order) so I had to make sure my config is part of a module loading after the modules that create classes used within this config

#

I think the simplest solution could be, to have your data in an asset that is soft referenced in your config. this way your data shouldn't break during init

ruby sleet
#

ah

#

but the problem is the optiona module makes it hard for me to initialize defaults

#

Thats why im struggling to find a solution. I use the module launch to check for data in the settings and it adds defaults if they arent present so that users dont have to define it.
I may just have to bite the bullet and make separate settings even if its ugly

floral flicker
#

well I don't think separate settings are uggly. I mean, as soon as they are stored as binary, you'll have corrupted settings as it can't quite be loaded anymore (if the blob doesn't have headers to skip not loadable blocks) if classes are missing.
so having settings extensions/ overrides, does make sense here, if you need it modular.

ruby sleet
#

im also gonna have to figure out how to refactor settings access cause i cant reference the optional module lke that