Accessing WidgetTree in EditorTime

So I’m trying to make a custom editor that gives the designer an extra text field in the details panel for every text box in a selected widget class.

I assumed the logic would be, property for TSubObject of XWidgetClass
Get chosen class from property’s CDO
Navigate the widget tree to find any text boxes in the widget

And this all conceptually works fine, save for the fact that there is no widget tree generated in the CDO. There’s no root widget, I presume none of the widgets that make up the UserWidget itself are constructed until we have an instance. But the data must be somewhere, because when the Widget it constructed it has some template to build itself from. Is there any way anyone knows of to access this information? All I need is the number of, and names of the text box widgets within this user widget, I don’t need to manipulate them.

Thanks for any help anyone can give!

You can get all the information you need from the Widget Tree in C++. If you need to expose it you could but considering the way it is traversed, the better option is to keep it in code.

The basics are you get a reference to the Widget Object with

TArray Objects;
DetailBuilder.GetObjectsBeingCustomized(Objects);

Then check to make sure you only have one, or you deal with multiple objects returns.
if (Objects.Num() != 1)
{ // multiple values returned }

Now you have the widget object but you need to cast it off for a weak reference.

TWeakObjectPtr MyObject = Cast(Objects[0].Get());

Now we have our Widget object, we can access the WidgetTree directly like so.

UWidgetTree* MyWidgetTree = MyObject->WidgetTree;

or

UWidget* FoundWidget = MyObject->WidgetTree->FindWidget("MyWidget");

Pretty much from here you have access to all the functions on this page.

Dont forget your includes. ( #include “Blueprint/WidgetTree.h” ) for example.