I would like to know how to spawn say static meshes (and spawn a material and assign it to the mesh) and assign the mesh to the actor itself as a component in Editor Time. This should be configurable for an arbitrary number of meshes defined through the details panel of the actor.
Context: To drag and drop a C++ actor into the viewport, and by means of it’s Details Panel, enter a number in a text box which represents the number of a particular static mesh that will be created (if you specify say 10 of these meshes, then 10 will be positioned neatly side-by-side for instance). Later, you should be able to adjust the detail to remove spawned meshes in real time.
When you press Play, the meshes remain in the world exactly as they did during Editor time. Any user scaling/transformation/and positioning should also be preserved.
So far, I have created a C++ Actor, with a bit of blueprint exposure (though I am not concerned with spawning a blueprint at this point).
I am using OnConstruction(FTransform z) to effort this. I do not wish to use the constructor of the actor as I wish to see the effects during editor time.
So far, I am aware that using any ConstructorHelpers will crash UE the moment you drag the actor onto the viewport.
CreateDefaultSubObject(Fname) will also crash the editor.
I have guessed once the component (as a UStaticMeshComponent) is instantiated, you can register, set positioning and attachments to unto the actor itself as need be.
What would be the typical process of spawning meshes (with its materials assigned) in realtime in the editor whilst preserving them for runtime? (The user may wish to specify the number of meshes to spawn and position/scale them perhaps prior to testing the Game world out).
Many thanks guys for your help,