Announcement

Collapse
No announcement yet.

Custom Editor Struct Array Details Customization

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Custom Editor Struct Array Details Customization

    I'm trying to create a customized details view for an array of buttons (USTRUCT) but the details view is always blank. I think I'm missing something about properties, their values, and instancing in the editor. Here's some of the code that I've stripped down to the core parts of what I'm triyng todo.

    Code:
    void FRadialMenuWidgetDetailsCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailLayout)
    {
        // get the array of button structs (TArray<FRadialMenuButton> ButtonList)
        ButtonListPropertyHandle = DetailLayout.GetProperty(GET_MEMBER_NAME_CHECKED(URadialMenuWidget, ButtonList));
    
        TArray<TWeakObjectPtr<UObject>> radialMenus;
        DetailLayout.GetObjectsBeingCustomized(radialMenus);
        RadialMenuWidget = (URadialMenuWidget*)radialMenus[0].Get();
    
        DetailLayout.EditCategory("Radial Menu - Buttons")
        .AddCustomRow(NSLOCTEXT("NerveNet", "RadialMenuFunctionsLabel", "Radial Menu Functions"))
            .WholeRowContent()
            [
                SNew(SVerticalBox)
                    + SVerticalBox::Slot()
                    .AutoHeight()
                    [
                        SNew(SBorder).Padding(0.0f) [
                        SNew(SBorder).Padding(0.0f).BorderImage(FEditorStyle::GetBrush("ContentBrowser.ThumbnailShadow")) [
                        SNew(SBox).Padding(6.0f) [
                            SAssignNew(DetailsPanel, SBox)
                        ]]]
                    ]
            ];
    
        if (RadialMenuWidget->ButtonList.IsValidIndex(0))
           DetailsPanel->SetContent(GetDetailsView(0));
    }
    
    TSharedRef<SWidget> FRadialMenuWidgetDetailsCustomization::GetDetailsView(uint32 ButtonIndex)
    {
        TSharedPtr<IStructureDetailsView> detailsView;
    
        if (!RadialMenuWidget->ButtonList.IsValidIndex(ButtonIndex)) return SNew(SBox);
    
        FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
    
        FDetailsViewArgs viewArgs;
        FStructureDetailsViewArgs structViewArgs;
    
        TSharedPtr<IPropertyHandleArray> arrayPropertyHandle = ButtonListPropertyHandle->AsArray();
        TSharedPtr<IPropertyHandle> arrayStructPropertyHandle = arrayPropertyHandle->GetElement(ButtonIndex);
    
        void *structAddr;
        arrayStructPropertyHandle->GetValueData(structAddr);
    
        //FStructOnScope structScope = MakeShareable(new FStructOnScope(FRadialMenuButton::StaticStruct(), (uint8*)structAddr));
        FStructOnScope structScope = MakeShareable(new FStructOnScope(FRadialMenuButton::StaticStruct(), (uint8*)&RadialMenuWidget->ButtonList[ButtonIndex]));
        detailsView = PropertyModule.CreateStructureDetailView(viewArgs, structViewArgs, structScope, LOCTEXT("RadialMenuButtonDetailsLabel", "Radial Menu Button Details"));
    
        return detailsView->GetWidget().ToSharedRef();
    }
    I even tried getting the struct value through the property handle as commented out towards the bottom of the code.

    Can someone help me understand what is happening here? All that shows is a blank area inside the borders:

    Click image for larger version  Name:	ButtonDetailsView.png Views:	1 Size:	4.4 KB ID:	1534777
    Last edited by Messiah_of_Savants; 10-02-2018, 09:39 PM.
Working...
X