Moving a component added in BP to a c++ UPROPERTY

Hello Andrew!

Stepping in for John as I was chatting with some colleagues about this issue, and wanted to send over their thoughts on the matter!

They’re going to have to write some code up to perform this migration, probably external to the class. Native classes are loaded before BP classes, so PostLoad won’t work for this. It’ll have to be a separate script they can trigger in editor after the engine’s fully initialized and all of those classes are loaded. I’d add the component to the native base class with CreateDefaultSubobject and then script the transition as follows:

  1. Use the asset manager to scan for children of that native base class
  2. Cast the object in the `FAssetData` to a `UBlueprintGeneratedClass*`
  3. Loop through the `USCS_Node` array returned by the BP generated class’s `SimpleConstructionScript->GetAllNodes()`, filtering for the native component class you’re looking for by checking if the node’s `ComponentClass` field matches or is a child of the component class you’re looking for
  4. If you have a match, call `GetActualComponentTemplate()` on the node. Cast that to your native class and you’ll have the BP-added component’s CDO with its properties filled out.
  5. Copy the properties from that to the component you added to the native base class. Make sure to dirty and save the asset.

The issue you sent over should be resolved by 5.6, I see the last reply mention further tests on 5.2 and main failed to reproduce the issue, so not sure if that’s the same bug?

Let me know if this helps!

Thanks,

Kyle B.