Working in a custom C++ component, I’m trying to pull a list of child components when PostEditChangeProperty() is called (when a change is made to the component in the editor). However with my current setup, it always returns 0 child components, even when I know this to be false and have manually added child components myself.
Here is the incorrect code I currently have:
void UPickupObjectComponent::PostEditChangeProperty(FPropertyChangedEvent & e)
{
Super::PostEditChangeProperty(e);
TArray<USceneComponent*> Meshes;
GetChildrenComponents(false, Meshes);
if (Meshes.Num() > 0) {
UE_LOG(LogTemp, Warning, TEXT("Found %d static meshes"), Meshes.Num());
for (int i = 0; i < Meshes.Num(); i++) {
if (Meshes[i]->IsA(UStaticMeshComponent::StaticClass())) {
ChildMesh = Cast<UStaticMeshComponent>(Meshes[i]);
}
}
}
}
If I try to call GetChildrenComponents in the blueprint construction script it works. Is there a different function I need to call in c++ to get it to work in editor?