Can I use UObjects as value in config files?

Following the documentation:

I can’t see a way to set/create objects as values in the config file, that is if I have an object UServerSettings create an array of objects ServerSettings with values defined.

I know how to do that using structs, but I need them to be objects, I am currently creating new objects and copy the values from the structs in the initialize() method.

+ServerSettings=(Name="Local",URL="");is a struct and I want an UObject
+ServerSettings=(Name="AWS",URL=""); is a struct and I want an UObject

Is there a way to have an array of objects instead of Structs?


I am struggling with this as well Did you ever get an answer? The Default classes are UObjects and those are stored in the config files. But I can’t put an instance in a config.

I Realy like to understand this better.

I don’t know what the software engineering reasons for this are, but UObjects properies can’t have the config specifier. You can however, get around it
by using a FSoftObjectPath. That can have the config specifier. After that, you can cast it to your UObject type

UPROPERTY(Config, EditAnywhere, Category="SomeCategory")
FSoftObjectPath SomeObject;

//Definition of some class, maybe a subsystem?

UMyObject* CacheObject;

void InitOfSomeClass()
const UMySettings Settings = GetDefault<UMySettings>();

//Cache this for later, so you dont have to load it every time you need it
CacheObject = LoadObject<UMyObject>(nullptr, *Settings->SomeObject.ToString(), nullptr, LOAD_Async));