I would like to override the default class used for drag and drop in the editor for Static Meshes.
Right now when you drag and drop a Static Mesh asset into the scene it will create a StaticMeshActor using that static mesh asset.
I want to use a C++ Class which inherits from StaticMeshActor, let’s call it MyStaticMeshActor and make MyStaticMeshActor the default class for Static Mesh assets that are added to the scene using drag and drop operations.
As it is now, I have to add MyStaticMeshActor to the scene and select the static mesh I wish to use from the properties, this also has the disadvantage of having the default name being MyStaticMeshActor#, which makes for more work in renaming each actor used.
I had heard of the UActorFactory Classes from the Extending The Editor videos from Unreal and looked at the UActorFactoryStaticMesh class, however changing UActorFactoryStaticMesh requires the Unreal be built from source, which I have set up, though I don’t really like modifying the engine any more than I have to.
I was kind of hoping there would be an option to either change the Factory used for static meshes or there would be an editor option to change the default to an inherited class, though from all my searching I don’t think this is the case.
I think the best solution for my workflow is to create a plug-in that will replace the StaticMeshActor in the scene, copying the transform, name and static mesh properties, and assign that plug-in to a button or key board shortcut.
You should just be able to create your own UActorFactory-derived class (inside an editor module) and give it a higher priority than the default static mesh one has.
In your editor module StartupModule() function you need to first register your ActorFactory so the editor can use it:
if (GEditor)
{
UCustomFactory* NewFactory = NewObject<UCustomFactory>();
GEditor->ActorFactories.Insert(NewFactory,0);
}
In other modules they usually use “Add” rather than “Insert” but when spawning the actor the engine looks for the first actor factory that can spawn the actor from the asset. Normally this would be the UActorFactoryStaticMesh which is usually in index 1. So if you are adding it, it will add to the end of GEditor’s array of ActorFactories so your new factory wont be used.
Also don’t forget to unregister your custom factory in your module ShutdownModule function.