Announcement

Collapse
No announcement yet.

Change Default Actor Class used for Drag and Drop of Assets

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Change Default Actor Class used for Drag and Drop of Assets

    This is a copy of a question I posted here: https://answers.unrealengine.com/que...-and-drop.html
    Though up to now I have not had any luck with questions posted to the AnswerHub, so I thought I would also post the question here on the forums.

    ------------------------------------------------

    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.

    Any help would be greatly appreciated!

    #2
    There is a class called UActorFactoryStaticMesh that is responsible for creating an actor from a static mesh.
    Realistic Atmosphere 2.0 | YouTube | Forum | Marketplace

    Comment


      #3
      Thanks Robert,

      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.

      Thanks again for the response!

      Comment


        #4
        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.

        Comment


          #5
          kamrann Thank you I did not know that!

          What I just ended up doing was creating a Toolbar Button Plugin and adding this into PluginButtonClicked()

          Code:
             
              TSet ComponentsToConsider;
              ComponentsToConsider.Add("StaticMeshComponent");
          
              TArray SelectedActors;
              GEditor->GetSelectedActors()->GetSelectedObjects(SelectedActors);
          
              UClass* ReplaceWithClass = AInheritedStaticMeshActor::StaticClass();
          
              GEditor->ConvertActors(SelectedActors, ReplaceWithClass, ComponentsToConsider, true);
          I was completely unaware that UActorFactory Classes could override each other, I'll have to look into that.

          Comment

          Working...
          X