So I looked in the source code to create a plugin, I found a way to validate the clipboard.
It’s very strange, you have to select a component on an actor before making the copy, it creates a anything in it, then after the clipboard is validated and it’s possible to make the paste.
I may have found a track in the source code, the validation starts with check if it is components and not actors, I will try to redo a function for that, and maybe it will be possible to make the prefab system directly in the engine.
UUnrealEdEngine::edactPasteSelected(UWorld* InWorld, bool bDuplicate, bool bOffsetLocations, bool bWarnIfHidden, FString* SourceData)
if (GetSelectedComponentCount() > 0)
{
AActor* SelectedActor = CastChecked<AActor>(*GetSelectedActorIterator());
TArray<UActorComponent*> PastedComponents;
FComponentEditorUtils::PasteComponents(PastedComponents, SelectedActor, SelectedActor->GetRootComponent());
if (PastedComponents.Num() > 0)
{
// Make sure all the SCS trees have a chance to update
FLevelEditorModule& LevelEditor = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
LevelEditor.BroadcastComponentsEdited();
// Select the new clones
USelection* ComponentSelection = GetSelectedComponents();
ComponentSelection->Modify(false);
ComponentSelection->BeginBatchSelectOperation();
ComponentSelection->DeselectAll();
for (UActorComponent* PastedComp : PastedComponents)
{
GEditor->SelectComponent(PastedComp, true, false);
}
ComponentSelection->EndBatchSelectOperation(true);
}
}
else