A method for Automatically validating Actors or Assets
Usable only in C++, override the function CheckForErrors
.
This function runs during MapCheck. Use FMessageLog to log data from it. This runs against the instance placed into the level, so you can use this to validate components or any other state.
The code here would check if there are any primitive components in the actor which have Can Ever Affect Navigation enabled and report them as errors:
void AItemBase::CheckForErrors()
{
auto Log = FMessageLog("MapCheck");
ForEachComponent<UPrimitiveComponent>(false, [this, &Log](const UPrimitiveComponent* Comp)
{
if(Comp->CanEverAffectNavigation())
{
Log.Error(INVTEXT("Primitive component in item has affect navigation enabled"))
->AddToken(FUObjectToken::Create(this));
}
});
Super::CheckForErrors();
}