I am writing some asset validation that is intended to run on PackedLevelActor blueprints. Opening the PackedLevelActor in Content Browser, I can see it has many dozens of InstancedStaticMesh components. In the validation, I can’t seem to access any of the ISM components. Is there anything special I need to do to be able to access the ISM components of the default blueprint object?
{
UBlueprint* Blueprint = Cast<UBlueprint>(InAsset);
UClass* BlueprintClass = Blueprint->GeneratedClass.Get();
UObject* CDO = BlueprintClass->GetDefaultObject();
if (AActor* Actor = Cast<AActor>(CDO))
{
TArray<UActorComponent*> Components;
Actor->GetComponents(Components);
// Components only contains the root LevelInstanceComponent
}
// Also try with a property iterator
for (TPropertyValueIterator<const FProperty> It(BlueprintClass, CDO); It; ++It)
{
const FProperty* Property = It.Key();
if (const FObjectProperty* Prop = CastField<FObjectProperty>(Property))
{
// I can verify the ISM components are iterated on here
if (Prop->PropertyClass == UInstancedStaticMeshComponent::StaticClass())
{
// Value is always null here
if (UObject* Value = Prop->GetObjectPropertyValue_InContainer(CDO))
{
if (UInstancedStaticMeshComponent* InstancedStaticMeshComponent = Cast<UInstancedStaticMeshComponent>(Value))
{
// Do something with the ISM component
}
}
}
}
}
[Attachment Removed]