UProceduralMeshComponent to UStaticMeshComponent

Hi, I try to create some dynamic actors from a plugin that I wrote. Constructing a UProceduralMeshComponent works fine so now I’d like to create an actor (e.g. a AStaticMeshActor) with that specific mesh. An AStaticMeshActor has a StaticMeshComponent as property so I guess that would be the right point to start. Unfortunately, I do not know how to convert a UProceduralMeshComponent to an UStaticMeshComponent.

Any ideas?

P.s. If you have any better way to assign a procedural mesh to an actor let me know.

You would have to generate a UStaticMesh from the data of your UProceduralMeshComponent component, a UStaticMeshComponent requires an asset to work.

To create your asset you might want to have a closer look into UFbxFactory which is where the engine imports FBX files, UObject* UFbxFactory::FactoryCreateBinary does a lot of work on the issue.