Hi [mention removed],
Sorry for the delay. I’ve run the test and in my case I can reproduce the first part of the issue: the validation commandlet does report the actor instances as still having the component, even though the component has already been removed from the Blueprint class.
However, my results differ from yours in the next step. After rebuilding the level using WorldPartitionBuilderCommandlet, the level appears to be rebuilt correctly. When I run the validator again afterwards, the component is no longer reported on the actor instances in the World Partition level.
For reference, here are the commandlets I used for the test::
Validate Commandlet
"MyEnginePath\UE_5.6\Engine\Binaries\Win64\UnrealEditor-Cmd.exe" "MyProjectPath\UE_561\UE_561.uproject" -run=DataValidation
Rebuild Commandlet
"MyEnginePath\UE_5.6\Engine\Binaries\Win64\UnrealEditor-Cmd.exe" "MyProjectPath\UE_561\UE_561.uproject" "/Game/ValidationRepro/ReproMap" -run=WorldPartitionBuilderCommandlet -builder=WorldPartitionResaveActorsBuilder -SCCProvider=None
This is the validator I am using to check for the component in the actor instances within the World Partition level:
#include "ReproRemovedComponentValidator.h"
#include "Engine/World.h"
#include "Engine/Level.h"
#include "GameFramework/Actor.h"
#include "AssetRegistry/AssetData.h"
#include "UE_561/ReproValidationComponent.h"
DEFINE_LOG_CATEGORY_STATIC(LogReproValidator, Display, All);
bool UReproRemovedComponentValidator::CanValidateAsset_Implementation(
const FAssetData& InAssetData,
UObject* InObject,
FDataValidationContext& InContext) const
{
return InObject && InObject->IsA<UWorld>();
}
EDataValidationResult UReproRemovedComponentValidator::ValidateLoadedAsset_Implementation(
const FAssetData& InAssetData, UObject* InObject, const UObject* InContext)
{
UWorld* World = Cast<UWorld>(InObject);
if (!World || !World->PersistentLevel)
{
return EDataValidationResult::NotValidated;
}
int32 MatchingActors = 0;
for (AActor* Actor : World->PersistentLevel->Actors)
{
if (!IsValid(Actor))
{
continue;
}
TInlineComponentArray<UReproValidationComponent*> Components;
Actor->GetComponents<UReproValidationComponent>(Components);
if (Components.Num() > 0)
{
MatchingActors++;
UE_LOG(LogReproValidator, Warning,
TEXT("Actor %s still contains UReproValidationComponent"),
*Actor->GetPathName());
AssetFails(
InContext,
FText::FromString(
FString::Printf(TEXT("Actor '%s' still contains UReproValidationComponent"),
*Actor->GetPathName())));
}
}
UE_LOG(LogReproValidator, Display,
TEXT("Validation finished. Actors with component: %d"),
MatchingActors);
return MatchingActors > 0 ? EDataValidationResult::Invalid
: EDataValidationResult::Valid;
}
bool UReproRemovedComponentValidator::IsEnabled() const
{
return true;
}
The steps I followed were the following:
1- Create an actor Blueprint and add an actor component to it.
2- Spawn multiple instances of the actor in a World Partition level.
3- Compile and save both the Blueprint and the level.
4- Remove the component from the Blueprint, then compile and save again.
5- Close the editor and run the DataValidation commandlet. At this point, my validator logs that the actor instances in the World Partition level still contain the component.
6- Run the WorldPartitionBuilderCommandlet. The build completes successfully.
7- Run the DataValidation commandlet again. This time the validator reports 0 errors.
Could you please let us know if I may have missed any of your steps? It is also possible that there is some difference between my setup and yours that could explain the issue. It would be helpful if you could try the code I provided and check whether you still encounter the same error.
Best Regards,
Joan