Add External Property to Details Panel
To add an external property from an object that is not being customised to your Detials Panel use:
IDetailPropertyRow* Row = <IDetailCategoryBuilder variable>.AddExternalObjectProperty({InObject}, PropertyName)
For the property name, you can use:
GET_MEMBER_NAME_CHECKED(<Class>, <Variable Name>)
If the variable is protected or private, use the string property name.
The row that gets generated by the category can have its Display Name edited:
Row.DisplayName(FText::FromString(VariableOverrideName));
To add it to a group rather than a category, generate the category row first, and then hide that row and use the property handle from the row to generate a new property row in the group.
Row->Visibility(EVisibility::Collapsed);
IDetailPropertyRow& NewGroupRow = NewGroup.AddPropertyRow(Row->GetPropertyHandle().ToSharedRef());
The Display Name can be set the same as above with the new group-generated row.
Examples:
TArray<UBoxComponent*> Killboxes = Settings->GetParentWaterfall()->GetAllKillboxes();
for (UBoxComponent* KillBox : Killboxes)
{
IDetailGroup& NewGroup = Cat_Kill.AddGroup(KillBox->GetFName(), FText::FromString(FName::NameToDisplayString(KillBox->GetName(), false)));
auto AddExternalPropertyToKillGroup = [&](FName PropertyName, FString VariableOverrideName = "")
{
IDetailPropertyRow* Row = Cat_Kill.AddExternalObjectProperty({ KillBox }, PropertyName);
if (Row)
{
Row->Visibility(EVisibility::Collapsed);
IDetailPropertyRow& NewGroupRow = NewGroup.AddPropertyRow(Row->GetPropertyHandle().ToSharedRef());
if (!VariableOverrideName.IsEmpty()) NewGroupRow.DisplayName(FText::FromString(VariableOverrideName));
}
};
AddExternalPropertyToKillGroup(USceneComponent::GetRelativeLocationPropertyName(), "Location");
AddExternalPropertyToKillGroup(USceneComponent::GetRelativeRotationPropertyName(), "Rotation");
AddExternalPropertyToKillGroup(USceneComponent::GetRelativeScale3DPropertyName(), "Scale");
AddExternalPropertyToKillGroup("BoxExtent", "Extent");
}
Last updated