Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

GraphEdit

Inherits: Control < CanvasItem < Node < Object

An editor for graph-like structures, using GraphNodes.

Description

GraphEdit provides tools for creation, manipulation, and display of various graphs. Its main purpose in the engine is to power the visual programming systems, such as visual shaders, but it is also available for use in user projects.

GraphEdit by itself is only an empty container, representing an infinite grid where GraphNodes can be placed. Each GraphNode represents a node in the graph, a single unit of data in the connected scheme. GraphEdit, in turn, helps to control various interactions with nodes and between nodes. When the user attempts to connect, disconnect, or delete a GraphNode, a signal is emitted in the GraphEdit, but no action is taken by default. It is the responsibility of the programmer utilizing this control to implement the necessary logic to determine how each request should be handled.

Performance: It is greatly advised to enable low-processor usage mode (see OS.low_processor_usage_mode) when using GraphEdits.

Properties

bool

clip_contents

true (overrides Control)

bool

connection_lines_antialiased

true

float

connection_lines_curvature

0.5

float

connection_lines_thickness

2.0

FocusMode

focus_mode

2 (overrides Control)

bool

minimap_enabled

true

float

minimap_opacity

0.65

Vector2

minimap_size

Vector2(240, 160)

PanningScheme

panning_scheme

0

bool

right_disconnects

false

Vector2

scroll_offset

Vector2(0, 0)

bool

show_arrange_button

true

bool

show_grid

true

bool

show_grid_buttons

true

bool

show_menu

true

bool

show_minimap_button

true

bool

show_zoom_buttons

true

bool

show_zoom_label

false

int

snapping_distance

20

bool

snapping_enabled

true

float

zoom

1.0

float

zoom_max

2.0736

float

zoom_min

0.232568

float

zoom_step

1.2

Methods

PackedVector2Array

_get_connection_line ( Vector2 from_position, Vector2 to_position ) virtual const

bool

_is_in_input_hotzone ( Object in_node, int in_port, Vector2 mouse_position ) virtual

bool

_is_in_output_hotzone ( Object in_node, int in_port, Vector2 mouse_position ) virtual

bool

_is_node_hover_valid ( StringName from_node, int from_port, StringName to_node, int to_port ) virtual

void

add_valid_connection_type ( int from_type, int to_type )

void

add_valid_left_disconnect_type ( int type )

void

add_valid_right_disconnect_type ( int type )

void

arrange_nodes ( )

void

clear_connections ( )

Error

connect_node ( StringName from_node, int from_port, StringName to_node, int to_port )

void

disconnect_node ( StringName from_node, int from_port, StringName to_node, int to_port )

void

force_connection_drag_end ( )

PackedVector2Array

get_connection_line ( Vector2 from_node, Vector2 to_node )

Dictionary[]

get_connection_list ( ) const

HBoxContainer

get_menu_hbox ( )

bool

is_node_connected ( StringName from_node, int from_port, StringName to_node, int to_port )

bool

is_valid_connection_type ( int from_type, int to_type ) const

void

remove_valid_connection_type ( int from_type, int to_type )

void

remove_valid_left_disconnect_type ( int type )

void

remove_valid_right_disconnect_type ( int type )

void

set_connection_activity ( StringName from_node, int from_port, StringName to_node, int to_port, float amount )

void

set_selected ( Node node )

Theme Properties

Color

activity

Color(1, 1, 1, 1)

Color

grid_major

Color(1, 1, 1, 0.2)

Color

grid_minor

Color(1, 1, 1, 0.05)

Color

selection_fill

Color(1, 1, 1, 0.3)

Color

selection_stroke

Color(1, 1, 1, 0.8)

int

port_hotzone_inner_extent

22

int

port_hotzone_outer_extent

26

Texture2D

grid_toggle

Texture2D

layout

Texture2D

minimap_toggle

Texture2D

snapping_toggle

Texture2D

zoom_in

Texture2D

zoom_out

Texture2D

zoom_reset

StyleBox

menu_panel

StyleBox

panel


Signals

begin_node_move ( )

Emitted at the beginning of a GraphNode movement.


connection_drag_ended ( )

Emitted at the end of a connection drag.


connection_drag_started ( StringName from_node, int from_port, bool is_output )

Emitted at the beginning of a connection drag.


connection_from_empty ( StringName to_node, int to_port, Vector2 release_position )

Emitted when user drags a connection from an input port into the empty space of the graph.


connection_request ( StringName from_node, int from_port, StringName to_node, int to_port )

Emitted to the GraphEdit when the connection between the from_port of the from_node GraphNode and the to_port of the to_node GraphNode is attempted to be created.


connection_to_empty ( StringName from_node, int from_port,