Table of Contents

Class GraphNode

Namespace
Godot
Assembly
GodotSharp.dll

GraphNode allows to create nodes for a GraphEdit graph with customizable content based on its child controls. GraphNode is derived from Container and it is responsible for placing its children on screen. This works similar to VBoxContainer. Children, in turn, provide GraphNode with so-called slots, each of which can have a connection port on either side.

Each GraphNode slot is defined by its index and can provide the node with up to two ports: one on the left, and one on the right. By convention the left port is also referred to as the input port and the right port is referred to as the output port. Each port can be enabled and configured individually, using different type and color. The type is an arbitrary value that you can define using your own considerations. The parent GraphEdit will receive this information on each connect and disconnect request.

Slots can be configured in the Inspector dock once you add at least one child Control. The properties are grouped by each slot's index in the "Slot" section.

Note: While GraphNode is set up using slots and slot indices, connections are made between the ports which are enabled. Because of that GraphEdit uses the port's index and not the slot's index. You can use GetInputPortSlot(int) and GetOutputPortSlot(int) to get the slot index from the port index.

public class GraphNode : GraphElement, IDisposable
Inheritance
GraphNode
Implements
Inherited Members

Constructors

GraphNode()

public GraphNode()

Properties

Title

The text displayed in the GraphNode's title bar.

public string Title { get; set; }

Property Value

string

Methods

ClearAllSlots()

Disables all slots of the GraphNode. This will remove all input/output ports from the GraphNode.

public void ClearAllSlots()

ClearSlot(int)

Disables the slot with the given slotIndex. This will remove the corresponding input and output port from the GraphNode.

public void ClearSlot(int slotIndex)

Parameters

slotIndex int

GetInputPortColor(int)

Returns the Color of the input port with the given portIdx.

public Color GetInputPortColor(int portIdx)

Parameters

portIdx int

Returns

Color

GetInputPortCount()

Returns the number of slots with an enabled input port.

public int GetInputPortCount()

Returns

int

GetInputPortPosition(int)

Returns the position of the input port with the given portIdx.

public Vector2 GetInputPortPosition(int portIdx)

Parameters

portIdx int

Returns

Vector2

GetInputPortSlot(int)

Returns the corresponding slot index of the input port with the given portIdx.

public int GetInputPortSlot(int portIdx)

Parameters

portIdx int

Returns

int

GetInputPortType(int)

Returns the type of the input port with the given portIdx.

public int GetInputPortType(int portIdx)

Parameters

portIdx int

Returns

int

GetOutputPortColor(int)

Returns the Color of the output port with the given portIdx.

public Color GetOutputPortColor(int portIdx)

Parameters

portIdx int

Returns

Color

GetOutputPortCount()

Returns the number of slots with an enabled output port.

public int GetOutputPortCount()

Returns

int

GetOutputPortPosition(int)

Returns the position of the output port with the given portIdx.

public Vector2 GetOutputPortPosition(int portIdx)

Parameters

portIdx int

Returns

Vector2

GetOutputPortSlot(int)

Returns the corresponding slot index of the output port with the given portIdx.

public int GetOutputPortSlot(int portIdx)

Parameters

portIdx int

Returns

int

GetOutputPortType(int)

Returns the type of the output port with the given portIdx.

public int GetOutputPortType(int portIdx)

Parameters

portIdx int

Returns

int

GetSlotColorLeft(int)

Returns the left (input) Color of the slot with the given slotIndex.

public Color GetSlotColorLeft(int slotIndex)

Parameters

slotIndex int

Returns

Color

GetSlotColorRight(int)

Returns the right (output) Color of the slot with the given slotIndex.

public Color GetSlotColorRight(int slotIndex)

Parameters

slotIndex int

Returns

Color

GetSlotTypeLeft(int)

Returns the left (input) type of the slot with the given slotIndex.

public int GetSlotTypeLeft(int slotIndex)

Parameters

slotIndex int

Returns

int

GetSlotTypeRight(int)

Returns the right (output) type of the slot with the given slotIndex.

public int GetSlotTypeRight(int slotIndex)

Parameters

slotIndex int

Returns

int

GetTitlebarHBox()

Returns the HBoxContainer used for the title bar, only containing a Label for displaying the title by default. This can be used to add custom controls to the title bar such as option or close buttons.

public HBoxContainer GetTitlebarHBox()

Returns

HBoxContainer

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

IsSlotDrawStylebox(int)

Returns true if the background StyleBox of the slot with the given slotIndex is drawn.

public bool IsSlotDrawStylebox(int slotIndex)

Parameters

slotIndex int

Returns

bool

IsSlotEnabledLeft(int)

Returns true if left (input) side of the slot with the given slotIndex is enabled.

public bool IsSlotEnabledLeft(int slotIndex)

Parameters

slotIndex int

Returns

bool

IsSlotEnabledRight(int)

Returns true if right (output) side of the slot with the given slotIndex is enabled.

public bool IsSlotEnabledRight(int slotIndex)

Parameters

slotIndex int

Returns

bool

SetSlot(int, bool, int, Color, bool, int, Color, Texture2D, Texture2D, bool)

Sets properties of the slot with the given slotIndex.

If enableLeftPort/enableRightPort is true, a port will appear and the slot will be able to be connected from this side.

With typeLeft/typeRight an arbitrary type can be assigned to each port. Two ports can be connected if they share the same type, or if the connection between their types is allowed in the parent GraphEdit (see AddValidConnectionType(int, int)). Keep in mind that the GraphEdit has the final say in accepting the connection. Type compatibility simply allows the ConnectionRequest signal to be emitted.

Ports can be further customized using colorLeft/colorRight and customIconLeft/customIconRight. The color parameter adds a tint to the icon. The custom icon can be used to override the default port dot.

Additionally, drawStylebox can be used to enable or disable drawing of the background stylebox for each slot. See slot.

Individual properties can also be set using one of the set_slot_* methods.

Note: This method only sets properties of the slot. To create the slot itself, add a Control-derived child to the GraphNode.

public void SetSlot(int slotIndex, bool enableLeftPort, int typeLeft, Color colorLeft, bool enableRightPort, int typeRight, Color colorRight, Texture2D customIconLeft = null, Texture2D customIconRight = null, bool drawStylebox = true)

Parameters

slotIndex int
enableLeftPort bool
typeLeft int
colorLeft Color
enableRightPort bool
typeRight int
colorRight Color
customIconLeft Texture2D
customIconRight Texture2D
drawStylebox bool

SetSlotColorLeft(int, Color)

Sets the Color of the left (input) side of the slot with the given slotIndex to color.

public void SetSlotColorLeft(int slotIndex, Color color)

Parameters

slotIndex int
color Color

SetSlotColorRight(int, Color)

Sets the Color of the right (output) side of the slot with the given slotIndex to color.

public void SetSlotColorRight(int slotIndex, Color color)

Parameters

slotIndex int
color Color

SetSlotDrawStylebox(int, bool)

Toggles the background StyleBox of the slot with the given slotIndex.

public void SetSlotDrawStylebox(int slotIndex, bool enable)

Parameters

slotIndex int
enable bool

SetSlotEnabledLeft(int, bool)

Toggles the left (input) side of the slot with the given slotIndex. If enable is true, a port will appear on the left side and the slot will be able to be connected from this side.

public void SetSlotEnabledLeft(int slotIndex, bool enable)

Parameters

slotIndex int
enable bool

SetSlotEnabledRight(int, bool)

Toggles the right (output) side of the slot with the given slotIndex. If enable is true, a port will appear on the right side and the slot will be able to be connected from this side.

public void SetSlotEnabledRight(int slotIndex, bool enable)

Parameters

slotIndex int
enable bool

SetSlotTypeLeft(int, int)

Sets the left (input) type of the slot with the given slotIndex to type. If the value is negative, all connections will be disallowed to be created via user inputs.

public void SetSlotTypeLeft(int slotIndex, int type)

Parameters

slotIndex int
type int

SetSlotTypeRight(int, int)

Sets the right (output) type of the slot with the given slotIndex to type. If the value is negative, all connections will be disallowed to be created via user inputs.

public void SetSlotTypeRight(int slotIndex, int type)

Parameters

slotIndex int
type int

_DrawPort(int, Vector2I, bool, Color)

public virtual void _DrawPort(int slotIndex, Vector2I position, bool left, Color color)

Parameters

slotIndex int
position Vector2I
left bool
color Color

Events

SlotUpdated

Emitted when any GraphNode's slot is updated.

public event GraphNode.SlotUpdatedEventHandler SlotUpdated

Event Type

GraphNode.SlotUpdatedEventHandler