# How to get list of blueprint child components at compile time in editor?

**URL:** <https://forums.unrealengine.com/t/how-to-get-list-of-blueprint-child-components-at-compile-time-in-editor/412553>\
**Category:** Blueprint\
**Tags:** construction, unreal-engine, Scripting, Components, question\
**Created:** [December 18, 2017, 3:27pm UTC](https://forums.unrealengine.com/t/how-to-get-list-of-blueprint-child-components-at-compile-time-in-editor/412553 "2017-12-18T15:27:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Finlaymcd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Finlaymcd](https://forums.unrealengine.com/u/Finlaymcd)\
**Post date:** [December 18, 2017, 3:27pm UTC](https://forums.unrealengine.com/t/how-to-get-list-of-blueprint-child-components-at-compile-time-in-editor/412553/1 "2017-12-18T15:27:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![carpet200](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@carpet200](https://forums.unrealengine.com/u/carpet200)\
**Post date:** [February 14, 2018, 1:58pm UTC](https://forums.unrealengine.com/t/how-to-get-list-of-blueprint-child-components-at-compile-time-in-editor/412553/2 "2018-02-14T13:58:39Z")

</div>

Here is the function you need. It will fire for each attached component at compile

PickupObjectComponent.h

```
virtual void OnChildAttached(USceneComponent* childComponent) override;

```

PickupObjectComponent.cpp

```
void UPickupObjectComponent::OnChildAttached(USceneComponent* ChildComponent)
{
    Super::OnChildAttached(ChildComponent);
    //Your code here
}
```

---

<div class="post-metadata">

**Author:** ![Finlaymcd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Finlaymcd](https://forums.unrealengine.com/u/Finlaymcd)\
**Post date:** [February 27, 2018, 8:10pm UTC](https://forums.unrealengine.com/t/how-to-get-list-of-blueprint-child-components-at-compile-time-in-editor/412553/3 "2018-02-27T20:10:36Z")

</div>

Thanks very much, I went for a different solution in the end but this will be useful in the future.
