Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

GraphNode

繼承: GraphElement < Container < Control < CanvasItem < Node < Object

帶有連接埠的容器,代表 GraphEdit 中的一個節點。

說明

GraphNode 能夠在 GraphEdit 圖中建立節點,節點會根據其子控制項定制內容。GraphNode 衍生自 Container,負責將其子節點放置在螢幕上。工作原理類似於 VBoxContainer。而子節點為 GraphNode 提供所謂的插槽,每個插槽的兩側都可以有一個連接埠。

GraphNode 的插槽由其索引定義,一個插槽可以為節點提供最多兩個埠:一個在左側,一個在右側。根據慣例,左側埠也被稱為輸入埠,右側埠被稱為輸出埠。每個埠都可以單獨啟用和配置,使用不同的型別和顏色。型別是你按照自己的需要來定義的任意值。父 GraphEdit 將在每個連接和斷開連接請求中收到此信息。

新增至少一個子 Control 後,就可以在“屬性檢視器”面板中配置插槽。這些屬性在“Slot”部分中按每個插槽的索引進行群組。

注意:雖然 GraphNode 是使用插槽和插槽索引設定的,但連接是在啟用的埠之間建立的。因此 GraphEdit 使用埠的索引,而不是插槽的索引。可以使用 get_input_port_slot()get_output_port_slot() 從埠索引中獲取插槽索引。

屬性

FocusMode

focus_mode

3 (overrides Control)

bool

ignore_invalid_connection_type

false

MouseFilter

mouse_filter

0 (overrides Control)

FocusMode

slots_focus_mode

3

String

title

""

方法

void

_draw_port(slot_index: int, position: Vector2i, left: bool, color: Color) virtual

void

clear_all_slots()

void

clear_slot(slot_index: int)

Color

get_input_port_color(port_idx: int)

int

get_input_port_count()

Vector2

get_input_port_position(port_idx: int)

int

get_input_port_slot(port_idx: int)

int

get_input_port_type(port_idx: int)

Color

get_output_port_color(port_idx: int)

int

get_output_port_count()

Vector2

get_output_port_position(port_idx: int)

int

get_output_port_slot(port_idx: int)

int

get_output_port_type(port_idx: int)

Color

get_slot_color_left(slot_index: int) const

Color

get_slot_color_right(slot_index: int) const

Texture2D

get_slot_custom_icon_left(slot_index: int) const

Texture2D

get_slot_custom_icon_right(slot_index: int) const

Variant

get_slot_metadata_left(slot_index: int) const

Variant

get_slot_metadata_right(slot_index: int) const

int

get_slot_type_left(slot_index: int) const

int

get_slot_type_right(slot_index: int) const

HBoxContainer

get_titlebar_hbox()

bool

is_slot_draw_stylebox(slot_index: int) const

bool

is_slot_enabled_left(slot_index: int) const

bool

is_slot_enabled_right(slot_index: int) const

void

set_slot(slot_index: int, enable_left_port: bool, type_left: int, color_left: Color, enable_right_port: bool, type_right: int, color_right: Color, custom_icon_left: Texture2D = null, custom_icon_right: Texture2D = null, draw_stylebox: bool = true)

void

set_slot_color_left(slot_index: int, color: Color)

void

set_slot_color_right(slot_index: int, color: Color)

void

set_slot_custom_icon_left(slot_index: int, custom_icon: Texture2D)

void

set_slot_custom_icon_right(slot_index: int, custom_icon: Texture2D)

void

set_slot_draw_stylebox(slot_index: int, enable: bool)

void

set_slot_enabled_left(slot_index: int, enable: bool)

void

set_slot_enabled_right(slot_index: int, enable: bool)

void

set_slot_metadata_left(slot_index: int, value: Variant)

void

set_slot_metadata_right(slot_index: int, value: Variant)

void

set_slot_type_left(slot_index: int, type: int)

void

set_slot_type_right(slot_index: int, type: int)

主題屬性

Color

resizer_color

Color(0.875, 0.875, 0.875, 1)

int

port_h_offset

0

int

separation

2

Texture2D

port

StyleBox

panel

StyleBox

panel_focus

StyleBox

panel_selected

StyleBox

slot

StyleBox

slot_selected

StyleBox

titlebar

StyleBox

titlebar_selected


訊號

slot_sizes_changed() 🔗

Emitted when any slot's size might have changed.


slot_updated(slot_index: int) 🔗

當任何圖形節點的插槽更新時發出。


屬性說明

bool ignore_invalid_connection_type = false 🔗

  • void set_ignore_invalid_connection_type(value: bool)

  • bool is_ignoring_valid_connection_type()

If true, you can connect ports with different types, even if the connection was not explicitly allowed in the parent GraphEdit.


FocusMode slots_focus_mode = 3 🔗

Determines how connection slots can be focused.


String title = "" 🔗

顯示在 GraphNode 標題列中的文字。


方法說明

void _draw_port(slot_index: int, position: Vector2i, left: bool, color: Color) virtual 🔗

There is currently no description for this method. Please help us by contributing one!


void clear_all_slots() 🔗

禁用 GraphNode 的所有輸入和輸出槽。


void clear_slot(slot_index: int) 🔗

使用給定的slot_index 停用插槽。這將從GraphNode 中刪除對應的輸入和輸出連接埠。


Color get_input_port_color(port_idx: int) 🔗

返回輸入連接埠 port_idxColor


int get_input_port_count() 🔗

返回漸變中的顏色數。


Vector2 get_input_port_position(port_idx: int) 🔗

返回與給定 port_idx 相關聯的點的位置。


int get_input_port_slot(port_idx: int) 🔗

返回輸入連接埠 port_idx 對應的插槽索引。


int get_input_port_type(port_idx: int) 🔗

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


Color get_output_port_color(port_idx: int) 🔗

返回輸出連接埠 port_idxColor


int get_output_port_count() 🔗

返回混合空間中的點的數量。


Vector2 get_output_port_position(port_idx: int) 🔗

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


int get_output_port_slot(port_idx: int) 🔗

返回輸出連接埠 port_idx 對應的插槽索引。


int get_output_port_type(port_idx: int) 🔗

返回輸出連接埠 port_idx 的型別。


Color get_slot_color_left(slot_index: int) const 🔗

返回索引為 slot_index 的插槽的左側(輸入)Color


Color get_slot_color_right(slot_index: int) const 🔗

返回索引為 slot_index 的插槽的右側(輸出)Color


Texture2D get_slot_custom_icon_left(slot_index: int) const 🔗

Returns the left (input) custom Texture2D of the slot with the given slot_index.


Texture2D get_slot_custom_icon_right(slot_index: int) const 🔗

Returns the right (output) custom Texture2D of the slot with the given slot_index.


Variant get_slot_metadata_left(slot_index: int) const 🔗

Returns the left (input) metadata of the slot with the given slot_index.


Variant get_slot_metadata_right(slot_index: int) const 🔗

Returns the right (output) metadata of the slot with the given slot_index.


int get_slot_type_left(slot_index: int) const 🔗

返回索引為 slot_index 的插槽的左側(輸入)型別。


int get_slot_type_right(slot_index: int) const 🔗

返回索引為 slot_index 的插槽的右側(輸出)型別。


HBoxContainer get_titlebar_hbox() 🔗

傳回標題列的HBoxContainer,預設只包含一個用於顯示標題的Label。可用於在標題列中新增自訂控制項,例如選項或關閉按鈕。


bool is_slot_draw_stylebox(slot_index: int) const 🔗

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


bool is_slot_enabled_left(slot_index: int) const 🔗

如果插槽 slot_index 的左側(輸入)被啟用,則返回 true


bool is_slot_enabled_right(slot_index: int) const 🔗

如果插槽 slot_index 的右側(輸出)被啟用,則返回 true


void set_slot(slot_index: int, enable_left_port: bool, type_left: int, color_left: Color, enable_right_port: bool, type_right: int, color_right: Color, custom_icon_left: Texture2D = null, custom_icon_right: Texture2D = null, draw_stylebox: bool = true) 🔗

設定具有 slot_index 索引的插槽的屬性。

如果 enable_left_port/enable_right_porttrue,則將出現一個埠,插槽將能夠從這一側連接。

使用 type_left/type_right 可以為每個埠分配一個任意型別。如果兩個埠具有相同的型別,或者如果它們的型別之間的連接在父 GraphEdit 中被允許(參見 GraphEdit.add_valid_connection_type()),那麼這兩個埠就可以被連接。請記住,GraphEdit 在接受連接上擁有最終決定權。型別相容性只允許發出 GraphEdit.connection_request 訊號。

可以使用 color_left/color_rightcustom_icon_left/custom_icon_right 進一步定制埠。顏色參數為圖示新增了一個色調。自定義圖示可以用來覆蓋預設的埠點。

此外,draw_stylebox 可以用來啟用或禁用每個插槽的背景樣式框的繪製。參見 slot

單個屬性也可以使用 set_slot_* 方法之一來設定。

注意:該方法只設定插槽的屬性。要建立插槽本身,請將 Control 衍生的子節點新增到該 GraphNode。


void set_slot_color_left(slot_index: int, color: Color) 🔗

將插槽 slot_index 左側(輸入)的 Color 設定為 color


void set_slot_color_right(slot_index: int, color: Color) 🔗

將插槽 slot_index 右側(輸出)的 Color 設定為 color


void set_slot_custom_icon_left(slot_index: int, custom_icon: Texture2D) 🔗

Sets the custom Texture2D of the left (input) side of the slot with the given slot_index to custom_icon.


void set_slot_custom_icon_right(slot_index: int, custom_icon: Texture2D) 🔗

Sets the custom Texture2D of the right (output) side of the slot with the given slot_index to custom_icon.


void set_slot_draw_stylebox(slot_index: int, enable: bool) 🔗

切換插槽 slot_index 的背景 StyleBox


void set_slot_enabled_left(slot_index: int, enable: bool) 🔗

切換插槽 slot_index 的左側(輸入)埠。如果enabletrue,則左側會出現一個埠,插槽可以從這一側連接。


void set_slot_enabled_right(slot_index: int, enable: bool) 🔗

切換插槽 slot_index 的右側(輸出)埠。如果enabletrue,則右側會出現一個埠,插槽可以從這一側連接。


void set_slot_metadata_left(slot_index: int, value: Variant) 🔗

Sets the custom metadata for the left (input) side of the slot with the given slot_index to value.


void set_slot_metadata_right(slot_index: int, value: Variant) 🔗

Sets the custom metadata for the right (output) side of the slot with the given slot_index to value.


void set_slot_type_left(slot_index: int, type: int) 🔗

將插槽 slot_index 的左側(輸入)型別設定為 type。如果值為負,則所有的連接將不允許通過使用者輸入來建立。


void set_slot_type_right(slot_index: int, type: int) 🔗

將插槽 slot_index 的右側(輸出)型別設定為 type。如果值為負,則所有的連接將不允許通過使用者輸入來建立。


主題屬性說明

Color resizer_color = Color(0.875, 0.875, 0.875, 1) 🔗

套用於調整尺寸大小圖示的顏色調變。


int port_h_offset = 0 🔗

埠的水平偏移量。


int separation = 2 🔗

埠之間的垂直距離。


Texture2D port 🔗

該圖示用於表示埠。


StyleBox panel 🔗

GraphNode 的預設背景。


StyleBox panel_focus 🔗

StyleBox used when the GraphNode is focused (when used with assistive apps).


StyleBox panel_selected 🔗

用於 GraphNode 的每個插槽的 StyleBox


StyleBox slot 🔗

用於 GraphNode 的每個插槽的 StyleBox


StyleBox slot_selected 🔗

StyleBox used when the slot is focused (when used with assistive apps).


StyleBox titlebar 🔗

用於 GraphNode 的每個插槽的 StyleBox


StyleBox titlebar_selected 🔗

用於 GraphNode 的每個插槽的 StyleBox