Download

4.24 UK2Node FName pin as drop down

I am trying to achieve something similar to this

https://answers.unrealengine.com/storage/temp/224371-dropdown.jpg

This question was asked before here, but since it was never answered and I have been trying for a couple of days now with no success, I thought I’d ask again and also share what I have found out.

So after trying to build my own node so that it can have a drop down, without success of course, I literally copied the source code of the UK2Node_GetDataTableRow to my UK2Node_GetDataTableRow_2 and thats the result

https://answers.unrealengine.com/storage/temp/298992-annotation-2020-04-02-132717.png

At this point I’m not even sure if it is even possible, the node works exactly the same but without showing a drop down for the Row Name

If anyone as any suggestion, I’d really appreciate it.

I posted the same thing in the Answer Hub here

The K2 node uses custom widgets.
That drop-down is done using a Text combo box widget:

Could you give me some more information on how to get started with using widgets for K2 nodes, I read about it once on the wiki, but since that’s gone now I’m a little lost.
And since there is no reference of any widget on the UK2Node_GetDataTableRow it must be declared somewhere else.

But thanks anyways, maybe I’ll figure it out myself.

First thing to do is find out what kind of node Pin is used for “RowName”, there must be custom types declared somewhere in the module’s source code.

Do you mean this part?



// Row Name pin
UEdGraphPin* RowNamePin = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Name, UK2Node_GetDataTableRow_2Helper::RowNamePinName);


That means it’s a UEdGraphSchema_K2::PC_Name meaning it’s a FName.

Because of this comment in the UK2Node_GetDataTableRow source


// When the DataTable pin gets a new value assigned, we need to update the Slate UI so that SGraphNodeCallParameterCollectionFunction will update the ParameterName drop down

I started digging to find references of the UK2Node_GetDataTableRow node, because it wasn’t working for my copy and the comment suggest the drop down is generated somewhere else… and I found this in BlueprintGraphPanelPinFactory.cpp


else if (Outer->IsA(UK2Node_GetDataTableRow::StaticClass()))
        {
            const UK2Node_GetDataTableRow* GetDataTableRowNode = CastChecked<UK2Node_GetDataTableRow>(Outer);
            DataTablePin = GetDataTableRowNode->GetDataTablePin();
        }

        if (DataTablePin)
        {
            if (DataTablePin->DefaultObject != nullptr && DataTablePin->LinkedTo.Num() == 0)
            {
                if (auto DataTable = Cast<UDataTable>(DataTablePin->DefaultObject))
                {
                    return SNew(SGraphPinDataTableRowName, InPin, DataTable);
                }
                if (DataTablePin->DefaultObject->IsA(UCurveTable::StaticClass()))
                {
                    UCurveTable* CurveTable = (UCurveTable*)DataTablePin->DefaultObject;
                    if (CurveTable)
                    {
                        TArray<TSharedPtr<FName>> RowNames;
                        /** Extract all the row names from the RowMap */
                        for (TMap<FName, FRealCurve*>::TConstIterator Iterator(CurveTable->GetRowMap()); Iterator; ++Iterator)
                        {
                            /** Create a simple array of the row names */
                            TSharedPtr<FName> RowNameItem = MakeShareable(new FName(Iterator.Key()));
                            RowNames.Add(RowNameItem);
                        }
                        return SNew(SGraphPinNameList, InPin, RowNames);
                    }
                }
            }
        }

It looks very promising, I don’t have a lot of time rn, so I’ll look into it later, but I’ll post my findings here

Hi Qygon, I was trying to do something similar.
Probably you’re already figured it out, but I discovered that it’s possible to create custom FGraphPinPanelFactory and register them like this:



TSharedPtr<FBlueprintGraphPanelPinFactory> BlueprintGraphPanelPinFactory = MakeShareable(new FBlueprintGraphPanelPinFactory());
FEdGraphUtilities::RegisterVisualPinFactory(BlueprintGraphPanelPinFactory); 

This code can put inside a module Startup function (for example an editor plugin). This seems what it need to be done in order to have custom pins for custom UK2Nodes.

Hi, I did figure it out, I was just busy but I will try to post my solution here in the near future.

Basically you create your own PinFactory then register that factory just like the Post above shows

Then you have to set up how your Pin is represented and do something similar to this, just in your Factory and probably not with a DataTable

Like I said I will post some code from my project for further explanation in the near future.