Add pin buttons on input AND output side

Hello there :slight_smile:

I’m developping a plugin where I need a node to have variable numbers of inputs and outputs.
I would like this custom node to have an “Add In Pin” button on left side of it, and an “Add Out Pin” button on the right side.

I already managed to have the classic “Add Pin” button on right side that adds an input pin, but I want to change this behavior.

Don’t hesitate to give me C++ and UE4 references, I already looked in them and couldn’t find how to use the “CreateOutputSideAddButton” and “CreateInputSideAddButton” of SGraphNode in my custom K2Node…

Any idea?
Thanks in advance :slight_smile:
Bye

So I think I found how to do it.

You would need to create a new SGraphNode (inherited from SGraphNodeK2Default if it’s in blueprints), and implement the methods:

virtual void CreateOutputSideAddButton(TSharedPtr<SVerticalBox> OutputBox) override;
virtual void CreateInputSideAddButton(TSharedPtr<SVerticalBox> InputBox) override;
virtual FReply OnAddPin() override;
virtual EVisibility IsAddPinButtonVisible() const override;

You can use the code present in SGraphNodeK2Sequence.cpp, as it basically does implement an “Add pin” button. Then, you can cast your node to anything custom you made and link those two buttons to different actions.

In order for the custom SGraphNode to be detected, you need to register it with a Factory. You can check on the wiki tutorial about custom blueprint pins, and readapt the factory part code to node instead of pins. It’s basically the same thing.