I have a USceneComponent with its child components in an Actor blueprint. I want to execute an action in Blueprint Editor (not in the game) when all its children components exist, but
void MySceneComponent::OnRegister()
{
Super::OnRegister();
// Getting all children components
TArray<TObjectPtr<USceneComponent>> AllChildren;
GetChildrenComponents(true, AllChildren);
UE_LOG(LogTemp, Warning, TEXT("All child num from entrypoint OnRegister: %d"), AllChildren.Num());
}
printed 0 from all entrypoints I managed to find (OnComponentCreated, PostInitProperties, PostReinitProperties, PostLoad, …).
After that, I decided a custom button in UE editor could help, because when you press it, Actor obviously created children of my component in the Blueprint Editor preview scene.
But using
IDetailLayoutBuilder* DetailLayout
passed into button onclicked in:
void FMeshCustomizationUICustomization::CustomizeDetails(IDetailLayoutBuilder& DetailLayout)
{
TArray<TWeakObjectPtr<UObject>> OutObjects;
DetailLayout.GetObjectsBeingCustomized(OutObjects);
IDetailCategoryBuilder& EditCategory = DetailLayout.EditCategory(
"Save", LOCTEXT("SaveCategoryName", "Save Settings"));
EditCategory.AddCustomRow(LOCTEXT("MeshCustomizationActionsSaveRow", "Actions"), false)
.NameContent()
[
SNew(SButton)
.ContentPadding(2)
.OnClicked(this, &FMeshCustomizationUICustomization::ApplyChanges, &DetailLayout)
[
SNew(STextBlock)
.Text(LOCTEXT("MeshCustomizationActionsApply", "Apply Changes"))
.ToolTipText(LOCTEXT("MeshCustomizationActionsApply_ToolTip",
"Apply customization in this blueprint."))
.Font(IDetailLayoutBuilder::GetDetailFont())
]
]
.ValueContent()
[
SNew(SButton)
.ContentPadding(2)
.OnClicked(this, &FMeshCustomizationUICustomization::SaveAssets, &DetailLayout)
[
SNew(STextBlock)
.Text(LOCTEXT("MeshCustomizationActionsSave", "Save"))
.ToolTipText(LOCTEXT("MeshCustomizationActionsSave_ToolTip",
"Save configuration into the specified directory and file."))
.Font(IDetailLayoutBuilder::GetDetailFont())
]
];
}
I get
TArray<TWeakObjectPtr<UObject>> WeakObjectsBeingCustomized;
DetailLayout->GetObjectsBeingCustomized(WeakObjectsBeingCustomized);
and it doesn’t work as well (ObjectBeingCustomized has 0 children too when I press button in the Blueprint Editor, but this works - has non-zero children - on the instances in the world). In fact, after every change in MyActor, new instance of component is created, while instance connected to the button remains the same and unknown.
So where can I get my entrypoint in MySceneComponent for getting all children of component in Blueprint Editor?