Announcement

Collapse
No announcement yet.

4.24 UK2Node FName pin as drop down

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

    4.24 UK2Node FName pin as drop down

    I am trying to achieve something similar to this


    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



    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
    Last edited by Qygon; 04-02-2020, 09:39 AM.


    Contact

    Marketplace Content
    Simple SaveGame Extension

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

    https://docs.unrealengine.com/en-US/...Box/index.html
    | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

    Comment


      #3
      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.


      Contact

      Marketplace Content
      Simple SaveGame Extension

      Comment


        #4
        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.
        | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

        Comment


          #5
          Do you mean this part?
          Code:
          // 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.


          Contact

          Marketplace Content
          Simple SaveGame Extension

          Comment


            #6
            Because of this comment in the UK2Node_GetDataTableRow source
            Code:
            // 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
            Code:
            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


            Contact

            Marketplace Content
            Simple SaveGame Extension

            Comment


              #7
              Originally posted by Qygon View Post
              Because of this comment in the UK2Node_GetDataTableRow source
              Code:
              // 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
              Code:
              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:
              Code:
              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.

              Comment


                #8
                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

                Originally posted by andrea.b View Post

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

                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

                Originally posted by Qygon View Post
                Code:
                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);
                         }
                      }
                   }
                }
                Like I said I will post some code from my project for further explanation in the near future.
                Last edited by Qygon; 04-27-2020, 04:46 AM.


                Contact

                Marketplace Content
                Simple SaveGame Extension

                Comment

                Working...
                X