Description

Factories registered to the PlacementSubsystem using 
UPlacementSubsystem::RegisterAssetFactory will always be added to the end of the AssetFactories array. Which means if there are any existing registered factories that pass the `IAssetFactoryInterface::CanPlaceElementsFromAssetData` check done in `UPlacementSubsystem::FindAssetFactoryFromAssetData` then the first of those existing factories will be used instead of the newly registered factory. 
 
Potential solutions to this include introducing sorting/ordering to the registered factories, similar to how UEditorEngine::InitEngine usesFCompareUActorFactoryByMenuPriority or adding a function similar to CanPlaceElementsFromAssetData in IAssetFactoryInterface called ShouldPlaceElementsFromAssetData that gets checked first and only returns true if that factory is the only one who should be placing that actor. 

Steps to Reproduce
  1. Create a new cpp class that derives from AVolume, called ANewVolume
  2. Create a new cpp class that derives from `
    UActorFactoryBoxVolume` called UNewVolumeFactory
  3. in UNewVolumeFactory override 
    UActorFactory::PreSpawnActor and either place a breakpoint in the new function or print out a log message
  4. in UNewVolumeFactory override 
    UActorFactory::CanCreateActorFrom and only return true if the assetdata matches ANewVolume
  5. Call UPlacementSubsystem::RegisterAssetFactory and 
    GEditor->ActorFactories.Add(NewObject<UNewVolumeFactory>()); at the startup of a project module or create a CallInEditor function to do this.
  6. Use the place actors menu to a ANewVolume actor in the level

Expected Result: The breakpoint or log created in step 3 should occur because UNewVolumeFactory was used to place the actor

Actual Result: No log or breakpoint will be hit because UActorFactoryBoxVolume will actually be used to place the actor

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-197945 in the post.

1
Login to Vote

By Design
ComponentUE - Editor - Workflow Systems
Affects Versions5.4
CreatedOct 13, 2023
ResolvedOct 17, 2023
UpdatedJan 20, 2024
View Jira Issue