My aim is make difficulty system that will edit Class Default Object values for any specified class. It's fastest way to make any properties that will dependent to difficulty by game designer (Class. Property name. Modifier - mult/add).
So. I can get
UClass. This object has default values that will be used when class will be instantiated. If I edit them the new object will contains edited values too.
The best way is recreate
ClassDefaultObject? As I see in the code, GetDefaultObject method can construct this object if it does not exists. So, tried to destroy and null the
ClassDefaultObject and call
UObject* CDO = ClassToEdit->ClassDefaultObject; CDO->ConditionalBeginDestroy(); ClassToEdit->ClassDefaultObject = nullptr; ClassToEdit->GetDefaultObject(true);
This code makes new CDO, but this CDO has wrong values, not the default that I seen before. This CDO has parent's default values. Why so?
Okay. It does't helps. Package reloading? I tried this:
UPackage* package = ClassToEdit->GetOuterUPackage(); package = ReloadPackage(package, 0);
But this causes very bad effects (in
PIE). Every object that links to this object will be reloaded too? Each BeginPlay in my level fires again after reloading. It's not good. I also got various errors/condition failures/assertions after this operation.
So, can I reload CDO defaults without full reload? I want to return previous (true) defaults to my CDO. Is that possible?