HI
I am working on a task where I need to add the variables from the widget selected in the WidgetClass of a widget component to the User Interface category of the widget component’s details panel, so they can be viewed there.
But
void FDetailCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder)
{
IDetailCategoryBuilder& UserInterfaceCategory = DetailBuilder.EditCategory(“UserInterface”);
TSharedRef<IPropertyHandle> WidgetClassProperty = DetailBuilder.GetProperty("WidgetClass", UWidgetComponent::StaticClass());
UObject* WidgetClassObject = nullptr;
if (WidgetClassProperty->GetValue(WidgetClassObject) == FPropertyAccess::Success)
{
UClass* WidgetClass = Cast<UClass>(WidgetClassObject);
if (WidgetClass && WidgetClass->IsChildOf(UMyWidgetClass::StaticClass()))
{
for (TFieldIterator<FProperty> PropIt(WidgetClass); PropIt; ++PropIt)
{
FProperty* Property = *PropIt;
if (Property)
{
TSharedRef<IPropertyHandle> PropertyHandle = DetailBuilder.GetProperty(Property->GetFName(), WidgetClass);
if (PropertyHandle->IsValidHandle())
{
UserInterfaceCategory.AddProperty(PropertyHandle);
}
}
}
}
}
}
in this code, when i builded and checked in project, not thing happened,
the Log said PropertyHandle is not valid.
what is the problem?
Thx.