mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2025-12-31 09:49:22 +03:00
1697 lines
90 KiB
ReStructuredText
1697 lines
90 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. _class_GraphEdit:
|
|
|
|
GraphEdit
|
|
=========
|
|
|
|
**实验性:** This class may be changed or removed in future versions.
|
|
|
|
**继承:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
图结构编辑器,使用 :ref:`GraphNode<class_GraphNode>`\ 。
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
描述
|
|
----
|
|
|
|
**GraphEdit** 提供了用于对各种图进行创建、操作、显示的工具。它在引擎中的主要目的是驱动可视化编程系统,例如可视化着色器,但也可以在用户项目中使用。
|
|
|
|
\ **GraphEdit** 本身只是一个空容器,表示一个可以放置 :ref:`GraphNode<class_GraphNode>` 的无限栅格。每个 :ref:`GraphNode<class_GraphNode>` 代表图中的一个节点,是连接方案中的单个数据单元。而 **GraphEdit** 则有助于控制节点和节点之间的各种交互。当用户尝试连接、断开或删除一个 :ref:`GraphNode<class_GraphNode>` 时,\ **GraphEdit** 中会发出对应的信号,但默认情况下不执行任何动作。使用此控件的程序员负责实现必要的逻辑,来确定应如何处理每个请求。
|
|
|
|
\ **性能:**\ 强烈建议在使用 GraphEdit 时启用低处理器使用模式(见 :ref:`OS.low_processor_usage_mode<class_OS_property_low_processor_usage_mode>`\ )。
|
|
|
|
\ **注意:**\ 请注意,由于技术限制,\ :ref:`Node.get_children()<class_Node_method_get_children>` 还将返回名为 ``_connection_layer`` 的连接层节点。该行为可能会在未来版本中发生变化。
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
属性
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | clip_contents | ``true`` (overrides :ref:`Control<class_Control_property_clip_contents>`) |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`connection_lines_antialiased<class_GraphEdit_property_connection_lines_antialiased>` | ``true`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`connection_lines_curvature<class_GraphEdit_property_connection_lines_curvature>` | ``0.5`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`connection_lines_thickness<class_GraphEdit_property_connection_lines_thickness>` | ``4.0`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] | :ref:`connections<class_GraphEdit_property_connections>` | ``[]`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`FocusMode<enum_Control_FocusMode>` | focus_mode | ``2`` (overrides :ref:`Control<class_Control_property_focus_mode>`) |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`GridPattern<enum_GraphEdit_GridPattern>` | :ref:`grid_pattern<class_GraphEdit_property_grid_pattern>` | ``0`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`minimap_enabled<class_GraphEdit_property_minimap_enabled>` | ``true`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`minimap_opacity<class_GraphEdit_property_minimap_opacity>` | ``0.65`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`minimap_size<class_GraphEdit_property_minimap_size>` | ``Vector2(240, 160)`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`PanningScheme<enum_GraphEdit_PanningScheme>` | :ref:`panning_scheme<class_GraphEdit_property_panning_scheme>` | ``0`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`right_disconnects<class_GraphEdit_property_right_disconnects>` | ``false`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`scroll_offset<class_GraphEdit_property_scroll_offset>` | ``Vector2(0, 0)`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`show_arrange_button<class_GraphEdit_property_show_arrange_button>` | ``true`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`show_grid<class_GraphEdit_property_show_grid>` | ``true`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`show_grid_buttons<class_GraphEdit_property_show_grid_buttons>` | ``true`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`show_menu<class_GraphEdit_property_show_menu>` | ``true`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`show_minimap_button<class_GraphEdit_property_show_minimap_button>` | ``true`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`show_zoom_buttons<class_GraphEdit_property_show_zoom_buttons>` | ``true`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`show_zoom_label<class_GraphEdit_property_show_zoom_label>` | ``false`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`snapping_distance<class_GraphEdit_property_snapping_distance>` | ``20`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`snapping_enabled<class_GraphEdit_property_snapping_enabled>` | ``true`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`Dictionary<class_Dictionary>` | :ref:`type_names<class_GraphEdit_property_type_names>` | ``{}`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`zoom<class_GraphEdit_property_zoom>` | ``1.0`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`zoom_max<class_GraphEdit_property_zoom_max>` | ``2.0736003`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`zoom_min<class_GraphEdit_property_zoom_min>` | ``0.23256795`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`zoom_step<class_GraphEdit_property_zoom_step>` | ``1.2`` |
|
|
+------------------------------------------------------------------+--------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
方法
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`_get_connection_line<class_GraphEdit_private_method__get_connection_line>`\ (\ from_position\: :ref:`Vector2<class_Vector2>`, to_position\: :ref:`Vector2<class_Vector2>`\ ) |virtual| |const| |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`_is_in_input_hotzone<class_GraphEdit_private_method__is_in_input_hotzone>`\ (\ in_node\: :ref:`Object<class_Object>`, in_port\: :ref:`int<class_int>`, mouse_position\: :ref:`Vector2<class_Vector2>`\ ) |virtual| |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`_is_in_output_hotzone<class_GraphEdit_private_method__is_in_output_hotzone>`\ (\ in_node\: :ref:`Object<class_Object>`, in_port\: :ref:`int<class_int>`, mouse_position\: :ref:`Vector2<class_Vector2>`\ ) |virtual| |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`_is_node_hover_valid<class_GraphEdit_private_method__is_node_hover_valid>`\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`\ ) |virtual| |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`add_valid_connection_type<class_GraphEdit_method_add_valid_connection_type>`\ (\ from_type\: :ref:`int<class_int>`, to_type\: :ref:`int<class_int>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`add_valid_left_disconnect_type<class_GraphEdit_method_add_valid_left_disconnect_type>`\ (\ type\: :ref:`int<class_int>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`add_valid_right_disconnect_type<class_GraphEdit_method_add_valid_right_disconnect_type>`\ (\ type\: :ref:`int<class_int>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`arrange_nodes<class_GraphEdit_method_arrange_nodes>`\ (\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`attach_graph_element_to_frame<class_GraphEdit_method_attach_graph_element_to_frame>`\ (\ element\: :ref:`StringName<class_StringName>`, frame\: :ref:`StringName<class_StringName>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`clear_connections<class_GraphEdit_method_clear_connections>`\ (\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`connect_node<class_GraphEdit_method_connect_node>`\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`, keep_alive\: :ref:`bool<class_bool>` = false\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`detach_graph_element_from_frame<class_GraphEdit_method_detach_graph_element_from_frame>`\ (\ element\: :ref:`StringName<class_StringName>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`disconnect_node<class_GraphEdit_method_disconnect_node>`\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`force_connection_drag_end<class_GraphEdit_method_force_connection_drag_end>`\ (\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Array<class_Array>`\[:ref:`StringName<class_StringName>`\] | :ref:`get_attached_nodes_of_frame<class_GraphEdit_method_get_attached_nodes_of_frame>`\ (\ frame\: :ref:`StringName<class_StringName>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Dictionary<class_Dictionary>` | :ref:`get_closest_connection_at_point<class_GraphEdit_method_get_closest_connection_at_point>`\ (\ point\: :ref:`Vector2<class_Vector2>`, max_distance\: :ref:`float<class_float>` = 4.0\ ) |const| |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_connection_count<class_GraphEdit_method_get_connection_count>`\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`get_connection_line<class_GraphEdit_method_get_connection_line>`\ (\ from_node\: :ref:`Vector2<class_Vector2>`, to_node\: :ref:`Vector2<class_Vector2>`\ ) |const| |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] | :ref:`get_connection_list_from_node<class_GraphEdit_method_get_connection_list_from_node>`\ (\ node\: :ref:`StringName<class_StringName>`\ ) |const| |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] | :ref:`get_connections_intersecting_with_rect<class_GraphEdit_method_get_connections_intersecting_with_rect>`\ (\ rect\: :ref:`Rect2<class_Rect2>`\ ) |const| |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`GraphFrame<class_GraphFrame>` | :ref:`get_element_frame<class_GraphEdit_method_get_element_frame>`\ (\ element\: :ref:`StringName<class_StringName>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`HBoxContainer<class_HBoxContainer>` | :ref:`get_menu_hbox<class_GraphEdit_method_get_menu_hbox>`\ (\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_node_connected<class_GraphEdit_method_is_node_connected>`\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_valid_connection_type<class_GraphEdit_method_is_valid_connection_type>`\ (\ from_type\: :ref:`int<class_int>`, to_type\: :ref:`int<class_int>`\ ) |const| |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`remove_valid_connection_type<class_GraphEdit_method_remove_valid_connection_type>`\ (\ from_type\: :ref:`int<class_int>`, to_type\: :ref:`int<class_int>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`remove_valid_left_disconnect_type<class_GraphEdit_method_remove_valid_left_disconnect_type>`\ (\ type\: :ref:`int<class_int>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`remove_valid_right_disconnect_type<class_GraphEdit_method_remove_valid_right_disconnect_type>`\ (\ type\: :ref:`int<class_int>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_connection_activity<class_GraphEdit_method_set_connection_activity>`\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`, amount\: :ref:`float<class_float>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_selected<class_GraphEdit_method_set_selected>`\ (\ node\: :ref:`Node<class_Node>`\ ) |
|
|
+------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
主题属性
|
|
--------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`activity<class_GraphEdit_theme_color_activity>` | ``Color(1, 1, 1, 1)`` |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`connection_hover_tint_color<class_GraphEdit_theme_color_connection_hover_tint_color>` | ``Color(0, 0, 0, 0.3)`` |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`connection_rim_color<class_GraphEdit_theme_color_connection_rim_color>` | ``Color(0.1, 0.1, 0.1, 0.6)`` |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`connection_valid_target_tint_color<class_GraphEdit_theme_color_connection_valid_target_tint_color>` | ``Color(1, 1, 1, 0.4)`` |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`grid_major<class_GraphEdit_theme_color_grid_major>` | ``Color(1, 1, 1, 0.2)`` |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`grid_minor<class_GraphEdit_theme_color_grid_minor>` | ``Color(1, 1, 1, 0.05)`` |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`selection_fill<class_GraphEdit_theme_color_selection_fill>` | ``Color(1, 1, 1, 0.3)`` |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Color<class_Color>` | :ref:`selection_stroke<class_GraphEdit_theme_color_selection_stroke>` | ``Color(1, 1, 1, 0.8)`` |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`connection_hover_thickness<class_GraphEdit_theme_constant_connection_hover_thickness>` | ``0`` |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`port_hotzone_inner_extent<class_GraphEdit_theme_constant_port_hotzone_inner_extent>` | ``22`` |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`port_hotzone_outer_extent<class_GraphEdit_theme_constant_port_hotzone_outer_extent>` | ``26`` |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Texture2D<class_Texture2D>` | :ref:`grid_toggle<class_GraphEdit_theme_icon_grid_toggle>` | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Texture2D<class_Texture2D>` | :ref:`layout<class_GraphEdit_theme_icon_layout>` | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Texture2D<class_Texture2D>` | :ref:`minimap_toggle<class_GraphEdit_theme_icon_minimap_toggle>` | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Texture2D<class_Texture2D>` | :ref:`snapping_toggle<class_GraphEdit_theme_icon_snapping_toggle>` | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Texture2D<class_Texture2D>` | :ref:`zoom_in<class_GraphEdit_theme_icon_zoom_in>` | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Texture2D<class_Texture2D>` | :ref:`zoom_out<class_GraphEdit_theme_icon_zoom_out>` | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`Texture2D<class_Texture2D>` | :ref:`zoom_reset<class_GraphEdit_theme_icon_zoom_reset>` | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`StyleBox<class_StyleBox>` | :ref:`menu_panel<class_GraphEdit_theme_style_menu_panel>` | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`StyleBox<class_StyleBox>` | :ref:`panel<class_GraphEdit_theme_style_panel>` | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
| :ref:`StyleBox<class_StyleBox>` | :ref:`panel_focus<class_GraphEdit_theme_style_panel_focus>` | |
|
|
+-----------------------------------+-----------------------------------------------------------------------------------------------------------+-------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
信号
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_begin_node_move:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**begin_node_move**\ (\ ) :ref:`🔗<class_GraphEdit_signal_begin_node_move>`
|
|
|
|
在 :ref:`GraphElement<class_GraphElement>` 移动开始时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_connection_drag_ended:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**connection_drag_ended**\ (\ ) :ref:`🔗<class_GraphEdit_signal_connection_drag_ended>`
|
|
|
|
在连接拖动结束时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_connection_drag_started:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**connection_drag_started**\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, is_output\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_GraphEdit_signal_connection_drag_started>`
|
|
|
|
在连接拖动开始时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_connection_from_empty:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**connection_from_empty**\ (\ to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`, release_position\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_GraphEdit_signal_connection_from_empty>`
|
|
|
|
当用户将连接从输入端口拖动到图形的空白区域时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_connection_request:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**connection_request**\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GraphEdit_signal_connection_request>`
|
|
|
|
当尝试创建 ``from_node`` :ref:`GraphNode<class_GraphNode>` 的 ``from_port`` 和 ``to_node`` :ref:`GraphNode<class_GraphNode>` 的 ``to_port`` 之间的连接时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_connection_to_empty:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**connection_to_empty**\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, release_position\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_GraphEdit_signal_connection_to_empty>`
|
|
|
|
当用户将连接从输出端口拖动到图形的空白区域时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_copy_nodes_request:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**copy_nodes_request**\ (\ ) :ref:`🔗<class_GraphEdit_signal_copy_nodes_request>`
|
|
|
|
当该 **GraphEdit** 捕获 ``ui_copy`` 动作(默认情况下为 :kbd:`Ctrl + C`\ )时发出。一般来说,该信号指示所选的 :ref:`GraphElement<class_GraphElement>` 应被复制。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_cut_nodes_request:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**cut_nodes_request**\ (\ ) :ref:`🔗<class_GraphEdit_signal_cut_nodes_request>`
|
|
|
|
当该 **GraphEdit** 捕获 ``ui_cut`` 动作(默认情况下为 :kbd:`Ctrl + X`\ )时发出。一般来说,该信号指示所选的 :ref:`GraphElement<class_GraphElement>` 应被剪切。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_delete_nodes_request:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**delete_nodes_request**\ (\ nodes\: :ref:`Array<class_Array>`\[:ref:`StringName<class_StringName>`\]\ ) :ref:`🔗<class_GraphEdit_signal_delete_nodes_request>`
|
|
|
|
当该 **GraphEdit** 捕获 ``ui_graph_delete`` 动作(默认为 :kbd:`Delete`\ )时触发。
|
|
|
|
\ ``nodes`` 是应被移除的节点的名称的数组。这些通常包括所有选定的节点。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_disconnection_request:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**disconnection_request**\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GraphEdit_signal_disconnection_request>`
|
|
|
|
当试图移除 ``from_node`` :ref:`GraphNode<class_GraphNode>` 的 ``from_port`` 和 ``to_node`` :ref:`GraphNode<class_GraphNode>` 的 ``to_port`` 之间的连接时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_duplicate_nodes_request:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**duplicate_nodes_request**\ (\ ) :ref:`🔗<class_GraphEdit_signal_duplicate_nodes_request>`
|
|
|
|
当该 **GraphEdit** 捕获 ``ui_graph_duplicate`` 动作(默认为 :kbd:`Ctrl + D`\ )时触发。一般来说,该信号指示应被复制的所选的 :ref:`GraphElement<class_GraphElement>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_end_node_move:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**end_node_move**\ (\ ) :ref:`🔗<class_GraphEdit_signal_end_node_move>`
|
|
|
|
在 :ref:`GraphElement<class_GraphElement>` 移动结束时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_frame_rect_changed:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**frame_rect_changed**\ (\ frame\: :ref:`GraphFrame<class_GraphFrame>`, new_rect\: :ref:`Rect2<class_Rect2>`\ ) :ref:`🔗<class_GraphEdit_signal_frame_rect_changed>`
|
|
|
|
当 :ref:`GraphFrame<class_GraphFrame>` ``frame`` 大小调整为 ``new_rect`` 时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_graph_elements_linked_to_frame_request:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**graph_elements_linked_to_frame_request**\ (\ elements\: :ref:`Array<class_Array>`, frame\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_GraphEdit_signal_graph_elements_linked_to_frame_request>`
|
|
|
|
当一个或多个 :ref:`GraphElement<class_GraphElement>` 被放到名为 ``frame`` 的 :ref:`GraphFrame<class_GraphFrame>` 上,且它们之前未被附加到任何其他框中时发出。
|
|
|
|
\ ``elements`` 是要附加的 :ref:`GraphElement<class_GraphElement>` 数组。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_node_deselected:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**node_deselected**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_GraphEdit_signal_node_deselected>`
|
|
|
|
当给定的 :ref:`GraphElement<class_GraphElement>` 节点被取消选择时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_node_selected:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**node_selected**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_GraphEdit_signal_node_selected>`
|
|
|
|
当给定的 :ref:`GraphElement<class_GraphElement>` 节点被选中时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_paste_nodes_request:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**paste_nodes_request**\ (\ ) :ref:`🔗<class_GraphEdit_signal_paste_nodes_request>`
|
|
|
|
当该 **GraphEdit** 捕获 ``ui_paste`` 动作(默认为 :kbd:`Ctrl + V`\ )时触发。一般来说,该信号指示应被粘贴的先前复制的 :ref:`GraphElement<class_GraphElement>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_popup_request:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**popup_request**\ (\ at_position\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_GraphEdit_signal_popup_request>`
|
|
|
|
当请求弹出窗口时发出。在 GraphEdit 中右键点击时发生。\ ``at_position``\ 为该信号被发出时鼠标指针的位置。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_signal_scroll_offset_changed:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**scroll_offset_changed**\ (\ offset\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_GraphEdit_signal_scroll_offset_changed>`
|
|
|
|
当用户改变滚动偏移量时发出。在代码中改变滚动偏移量时,它不会被触发。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
枚举
|
|
----
|
|
|
|
.. _enum_GraphEdit_PanningScheme:
|
|
|
|
.. rst-class:: classref-enumeration
|
|
|
|
enum **PanningScheme**: :ref:`🔗<enum_GraphEdit_PanningScheme>`
|
|
|
|
.. _class_GraphEdit_constant_SCROLL_ZOOMS:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`PanningScheme<enum_GraphEdit_PanningScheme>` **SCROLL_ZOOMS** = ``0``
|
|
|
|
:kbd:`鼠标滚轮`\ 进行缩放,\ :kbd:`Ctrl + 鼠标滚轮`\ 进行视图的移动。
|
|
|
|
.. _class_GraphEdit_constant_SCROLL_PANS:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`PanningScheme<enum_GraphEdit_PanningScheme>` **SCROLL_PANS** = ``1``
|
|
|
|
:kbd:`鼠标滚轮`\ 进行视图的移动,\ :kbd:`Ctrl + 鼠标滚轮`\ 进行缩放。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _enum_GraphEdit_GridPattern:
|
|
|
|
.. rst-class:: classref-enumeration
|
|
|
|
enum **GridPattern**: :ref:`🔗<enum_GraphEdit_GridPattern>`
|
|
|
|
.. _class_GraphEdit_constant_GRID_PATTERN_LINES:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`GridPattern<enum_GraphEdit_GridPattern>` **GRID_PATTERN_LINES** = ``0``
|
|
|
|
使用实线绘制网格。
|
|
|
|
.. _class_GraphEdit_constant_GRID_PATTERN_DOTS:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`GridPattern<enum_GraphEdit_GridPattern>` **GRID_PATTERN_DOTS** = ``1``
|
|
|
|
使用点线绘制网格。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
属性说明
|
|
--------
|
|
|
|
.. _class_GraphEdit_property_connection_lines_antialiased:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **connection_lines_antialiased** = ``true`` :ref:`🔗<class_GraphEdit_property_connection_lines_antialiased>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_connection_lines_antialiased**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_connection_lines_antialiased**\ (\ )
|
|
|
|
如果为 ``true``\ ,节点之间的线将使用抗锯齿。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_connection_lines_curvature:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **connection_lines_curvature** = ``0.5`` :ref:`🔗<class_GraphEdit_property_connection_lines_curvature>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_connection_lines_curvature**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_connection_lines_curvature**\ (\ )
|
|
|
|
节点之间连线的曲率。0 得到的是直线。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_connection_lines_thickness:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **connection_lines_thickness** = ``4.0`` :ref:`🔗<class_GraphEdit_property_connection_lines_thickness>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_connection_lines_thickness**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_connection_lines_thickness**\ (\ )
|
|
|
|
节点之间连线的粗细。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_connections:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] **connections** = ``[]`` :ref:`🔗<class_GraphEdit_property_connections>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_connections**\ (\ value\: :ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\]\ )
|
|
- :ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] **get_connection_list**\ (\ )
|
|
|
|
:ref:`GraphNode<class_GraphNode>` 之间的连接。
|
|
|
|
连接由 :ref:`Dictionary<class_Dictionary>` 代表,形式为:
|
|
|
|
::
|
|
|
|
{
|
|
from_node: StringName,
|
|
from_port: int,
|
|
to_node: StringName,
|
|
to_port: int,
|
|
keep_alive: bool
|
|
}
|
|
|
|
重绘时,如果 ``keep_alive`` 为 ``false`` 的连接无效,则可能会被自动删除。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_grid_pattern:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`GridPattern<enum_GraphEdit_GridPattern>` **grid_pattern** = ``0`` :ref:`🔗<class_GraphEdit_property_grid_pattern>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_grid_pattern**\ (\ value\: :ref:`GridPattern<enum_GraphEdit_GridPattern>`\ )
|
|
- :ref:`GridPattern<enum_GraphEdit_GridPattern>` **get_grid_pattern**\ (\ )
|
|
|
|
绘制网格时使用的图案。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_minimap_enabled:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **minimap_enabled** = ``true`` :ref:`🔗<class_GraphEdit_property_minimap_enabled>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_minimap_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_minimap_enabled**\ (\ )
|
|
|
|
如果为 ``true``\ ,小图是可见的。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_minimap_opacity:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **minimap_opacity** = ``0.65`` :ref:`🔗<class_GraphEdit_property_minimap_opacity>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_minimap_opacity**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_minimap_opacity**\ (\ )
|
|
|
|
小图矩形的不透明度。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_minimap_size:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Vector2<class_Vector2>` **minimap_size** = ``Vector2(240, 160)`` :ref:`🔗<class_GraphEdit_property_minimap_size>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_minimap_size**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
|
|
- :ref:`Vector2<class_Vector2>` **get_minimap_size**\ (\ )
|
|
|
|
小图矩形的大小。地图自身基于网格区域的大小,并被缩放以适应这个矩形。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_panning_scheme:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`PanningScheme<enum_GraphEdit_PanningScheme>` **panning_scheme** = ``0`` :ref:`🔗<class_GraphEdit_property_panning_scheme>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_panning_scheme**\ (\ value\: :ref:`PanningScheme<enum_GraphEdit_PanningScheme>`\ )
|
|
- :ref:`PanningScheme<enum_GraphEdit_PanningScheme>` **get_panning_scheme**\ (\ )
|
|
|
|
定义使用鼠标滚轮平移的控制方案。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_right_disconnects:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **right_disconnects** = ``false`` :ref:`🔗<class_GraphEdit_property_right_disconnects>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_right_disconnects**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_right_disconnects_enabled**\ (\ )
|
|
|
|
如果为 ``true``\ ,通过拖动右端,可以断开 GraphEdit 中现有的连接。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_scroll_offset:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Vector2<class_Vector2>` **scroll_offset** = ``Vector2(0, 0)`` :ref:`🔗<class_GraphEdit_property_scroll_offset>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_scroll_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
|
|
- :ref:`Vector2<class_Vector2>` **get_scroll_offset**\ (\ )
|
|
|
|
滚动偏移量。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_show_arrange_button:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **show_arrange_button** = ``true`` :ref:`🔗<class_GraphEdit_property_show_arrange_button>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_show_arrange_button**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_showing_arrange_button**\ (\ )
|
|
|
|
如果为 ``true``\ ,则自动排列图形节点的按钮可见。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_show_grid:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **show_grid** = ``true`` :ref:`🔗<class_GraphEdit_property_show_grid>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_show_grid**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_showing_grid**\ (\ )
|
|
|
|
如果为 ``true``\ ,则该网格可见。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_show_grid_buttons:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **show_grid_buttons** = ``true`` :ref:`🔗<class_GraphEdit_property_show_grid_buttons>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_show_grid_buttons**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_showing_grid_buttons**\ (\ )
|
|
|
|
如果为 ``true``\ ,则允许配置栅格和吸附选项的按钮可见。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_show_menu:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **show_menu** = ``true`` :ref:`🔗<class_GraphEdit_property_show_menu>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_show_menu**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_showing_menu**\ (\ )
|
|
|
|
如果为 ``true``\ ,则菜单栏可见。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_show_minimap_button:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **show_minimap_button** = ``true`` :ref:`🔗<class_GraphEdit_property_show_minimap_button>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_show_minimap_button**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_showing_minimap_button**\ (\ )
|
|
|
|
如果为 ``true``\ ,则切换小地图的按钮可见。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_show_zoom_buttons:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **show_zoom_buttons** = ``true`` :ref:`🔗<class_GraphEdit_property_show_zoom_buttons>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_show_zoom_buttons**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_showing_zoom_buttons**\ (\ )
|
|
|
|
如果为 ``true``\ ,则允许更改和重置缩放级别的按钮可见。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_show_zoom_label:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **show_zoom_label** = ``false`` :ref:`🔗<class_GraphEdit_property_show_zoom_label>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_show_zoom_label**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_showing_zoom_label**\ (\ )
|
|
|
|
如果为 ``true``\ ,则使带有当前缩放级别的标签可见。缩放级别以百分比显示。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_snapping_distance:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`int<class_int>` **snapping_distance** = ``20`` :ref:`🔗<class_GraphEdit_property_snapping_distance>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_snapping_distance**\ (\ value\: :ref:`int<class_int>`\ )
|
|
- :ref:`int<class_int>` **get_snapping_distance**\ (\ )
|
|
|
|
吸附距离,单位为像素,也决定了栅格线距离。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_snapping_enabled:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **snapping_enabled** = ``true`` :ref:`🔗<class_GraphEdit_property_snapping_enabled>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_snapping_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_snapping_enabled**\ (\ )
|
|
|
|
如果为 ``true``\ ,启用自动吸附。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_type_names:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Dictionary<class_Dictionary>` **type_names** = ``{}`` :ref:`🔗<class_GraphEdit_property_type_names>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_type_names**\ (\ value\: :ref:`Dictionary<class_Dictionary>`\ )
|
|
- :ref:`Dictionary<class_Dictionary>` **get_type_names**\ (\ )
|
|
|
|
:ref:`Dictionary<class_Dictionary>` of human-readable port type names.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_zoom:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **zoom** = ``1.0`` :ref:`🔗<class_GraphEdit_property_zoom>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_zoom**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_zoom**\ (\ )
|
|
|
|
当前缩放值。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_zoom_max:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **zoom_max** = ``2.0736003`` :ref:`🔗<class_GraphEdit_property_zoom_max>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_zoom_max**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_zoom_max**\ (\ )
|
|
|
|
缩放上限。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_zoom_min:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **zoom_min** = ``0.23256795`` :ref:`🔗<class_GraphEdit_property_zoom_min>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_zoom_min**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_zoom_min**\ (\ )
|
|
|
|
缩放下限。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_property_zoom_step:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **zoom_step** = ``1.2`` :ref:`🔗<class_GraphEdit_property_zoom_step>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_zoom_step**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_zoom_step**\ (\ )
|
|
|
|
每个缩放级别的步长。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
方法说明
|
|
--------
|
|
|
|
.. _class_GraphEdit_private_method__get_connection_line:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`PackedVector2Array<class_PackedVector2Array>` **_get_connection_line**\ (\ from_position\: :ref:`Vector2<class_Vector2>`, to_position\: :ref:`Vector2<class_Vector2>`\ ) |virtual| |const| :ref:`🔗<class_GraphEdit_private_method__get_connection_line>`
|
|
|
|
可以重写的虚方法,以自定义如何绘制连接。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_private_method__is_in_input_hotzone:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **_is_in_input_hotzone**\ (\ in_node\: :ref:`Object<class_Object>`, in_port\: :ref:`int<class_int>`, mouse_position\: :ref:`Vector2<class_Vector2>`\ ) |virtual| :ref:`🔗<class_GraphEdit_private_method__is_in_input_hotzone>`
|
|
|
|
返回 ``mouse_position`` 是否在输入热区。
|
|
|
|
默认情况下,热区是一个 :ref:`Rect2<class_Rect2>`\ ,其中心位于 ``in_node``.\ :ref:`GraphNode.get_input_port_position()<class_GraphNode_method_get_input_port_position>`\ (``in_port``)(对于输出的情况,请改为调用 :ref:`GraphNode.get_output_port_position()<class_GraphNode_method_get_output_port_position>`\ )。热区的宽度是主题属性 ``port_grab_distance_horizontal`` 的两倍,高度是 ``port_grab_distance_vertical`` 的两倍。
|
|
|
|
下面是一个示例代码,以帮助入门:
|
|
|
|
::
|
|
|
|
func _is_in_input_hotzone(in_node, in_port, mouse_position):
|
|
var port_size = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical"))
|
|
var port_pos = in_node.get_position() + in_node.get_input_port_position(in_port) - port_size / 2
|
|
var rect = Rect2(port_pos, port_size)
|
|
|
|
return rect.has_point(mouse_position)
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_private_method__is_in_output_hotzone:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **_is_in_output_hotzone**\ (\ in_node\: :ref:`Object<class_Object>`, in_port\: :ref:`int<class_int>`, mouse_position\: :ref:`Vector2<class_Vector2>`\ ) |virtual| :ref:`🔗<class_GraphEdit_private_method__is_in_output_hotzone>`
|
|
|
|
返回 ``mouse_position`` 是否在输出热区。有关热区的更多信息,请参阅 :ref:`_is_in_input_hotzone()<class_GraphEdit_private_method__is_in_input_hotzone>`\ 。
|
|
|
|
下面是一个示例代码,以帮助入门:
|
|
|
|
::
|
|
|
|
func _is_in_output_hotzone(in_node, in_port, mouse_position):
|
|
var port_size = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical"))
|
|
var port_pos = in_node.get_position() + in_node.get_output_port_position(in_port) - port_size / 2
|
|
var rect = Rect2(port_pos, port_size)
|
|
|
|
return rect.has_point(mouse_position)
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_private_method__is_node_hover_valid:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **_is_node_hover_valid**\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`\ ) |virtual| :ref:`🔗<class_GraphEdit_private_method__is_node_hover_valid>`
|
|
|
|
当用户在有效端口上拖动连接时,该虚拟方法可用于插入额外的错误检测。
|
|
|
|
如果连接确实有效,则返回 ``true``\ ;如果连接不可能,则返回 ``false``\ 。如果连接是不可能的,则不会捕捉到该端口,因此不会发起对该端口的连接请求。
|
|
|
|
在该示例中,抑制了与同一节点的连接:
|
|
|
|
|
|
.. tabs::
|
|
|
|
.. code-tab:: gdscript
|
|
|
|
func _is_node_hover_valid(from, from_port, to, to_port):
|
|
return from != to
|
|
|
|
.. code-tab:: csharp
|
|
|
|
public override bool _IsNodeHoverValid(StringName fromNode, int fromPort, StringName toNode, int toPort)
|
|
{
|
|
return fromNode != toNode;
|
|
}
|
|
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_add_valid_connection_type:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **add_valid_connection_type**\ (\ from_type\: :ref:`int<class_int>`, to_type\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GraphEdit_method_add_valid_connection_type>`
|
|
|
|
允许两种不同端口类型之间的连接。端口类型是使用 :ref:`GraphNode.set_slot()<class_GraphNode_method_set_slot>` 方法为每个插槽的左右端口单独定义的。
|
|
|
|
另见 :ref:`is_valid_connection_type()<class_GraphEdit_method_is_valid_connection_type>` 和 :ref:`remove_valid_connection_type()<class_GraphEdit_method_remove_valid_connection_type>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_add_valid_left_disconnect_type:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **add_valid_left_disconnect_type**\ (\ type\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GraphEdit_method_add_valid_left_disconnect_type>`
|
|
|
|
如果 :ref:`GraphNode<class_GraphNode>` 插槽的左侧端口具有指定的类型,则允许在从该端口拖动时断开节点。另见 :ref:`remove_valid_left_disconnect_type()<class_GraphEdit_method_remove_valid_left_disconnect_type>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_add_valid_right_disconnect_type:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **add_valid_right_disconnect_type**\ (\ type\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GraphEdit_method_add_valid_right_disconnect_type>`
|
|
|
|
如果 :ref:`GraphNode<class_GraphNode>` 插槽的右侧端口具有指定的类型,则允许在从该端口拖动时断开节点。另见 :ref:`remove_valid_right_disconnect_type()<class_GraphEdit_method_remove_valid_right_disconnect_type>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_arrange_nodes:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **arrange_nodes**\ (\ ) :ref:`🔗<class_GraphEdit_method_arrange_nodes>`
|
|
|
|
重新排列布局中的选定节点,使连接之间的交叉最少,节点之间的水平和垂直间隙保持一致。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_attach_graph_element_to_frame:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **attach_graph_element_to_frame**\ (\ element\: :ref:`StringName<class_StringName>`, frame\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_GraphEdit_method_attach_graph_element_to_frame>`
|
|
|
|
将 ``element`` :ref:`GraphElement<class_GraphElement>` 附加到 ``frame`` :ref:`GraphFrame<class_GraphFrame>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_clear_connections:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **clear_connections**\ (\ ) :ref:`🔗<class_GraphEdit_method_clear_connections>`
|
|
|
|
移除节点之间的所有连接。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_connect_node:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Error<enum_@GlobalScope_Error>` **connect_node**\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`, keep_alive\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_GraphEdit_method_connect_node>`
|
|
|
|
在来源 :ref:`GraphNode<class_GraphNode>` 节点 ``from_node`` 的 ``from_port`` 端口和目标 :ref:`GraphNode<class_GraphNode>` 节点 ``to_node`` 的 ``to_port`` 端口之间创建连接。如果已存在连接,则不会创建连接。
|
|
|
|
\ ``keep_alive`` 为 ``false`` 的连接如果在重绘期间失效,则可能会被自动删除。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_detach_graph_element_from_frame:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **detach_graph_element_from_frame**\ (\ element\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_GraphEdit_method_detach_graph_element_from_frame>`
|
|
|
|
将 ``element`` :ref:`GraphElement<class_GraphElement>` 从其当前附加的 :ref:`GraphFrame<class_GraphFrame>` 中分离出来。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_disconnect_node:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **disconnect_node**\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GraphEdit_method_disconnect_node>`
|
|
|
|
移除 ``from_node`` :ref:`GraphNode<class_GraphNode>` 的 ``from_port`` 和 ``to_node`` :ref:`GraphNode<class_GraphNode>` 的 ``to_port`` 之间的连接。如果该连接不存在,则不移除任何连接。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_force_connection_drag_end:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **force_connection_drag_end**\ (\ ) :ref:`🔗<class_GraphEdit_method_force_connection_drag_end>`
|
|
|
|
结束当前连接的创建。换句话说,如果正在拖动一个连接,可以使用该方法中止该过程,并移除鼠标光标后面的线。
|
|
|
|
这最好与 :ref:`connection_drag_started<class_GraphEdit_signal_connection_drag_started>` 和 :ref:`connection_drag_ended<class_GraphEdit_signal_connection_drag_ended>` 一起使用,以添加自定义的行为,如通过快捷方式添加节点。
|
|
|
|
\ **注意:**\ 该方法会抑制除 :ref:`connection_drag_ended<class_GraphEdit_signal_connection_drag_ended>` 之外的任何其他连接请求信号。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_get_attached_nodes_of_frame:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Array<class_Array>`\[:ref:`StringName<class_StringName>`\] **get_attached_nodes_of_frame**\ (\ frame\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_GraphEdit_method_get_attached_nodes_of_frame>`
|
|
|
|
返回附加到给定名称的 :ref:`GraphFrame<class_GraphFrame>` 的节点名称数组。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_get_closest_connection_at_point:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Dictionary<class_Dictionary>` **get_closest_connection_at_point**\ (\ point\: :ref:`Vector2<class_Vector2>`, max_distance\: :ref:`float<class_float>` = 4.0\ ) |const| :ref:`🔗<class_GraphEdit_method_get_closest_connection_at_point>`
|
|
|
|
返回到屏幕空间中给定点的最近连接。如果在 ``max_distance`` 像素内未找到连接,则返回空的 :ref:`Dictionary<class_Dictionary>`\ 。
|
|
|
|
连接由以下形式的结构组成:
|
|
|
|
::
|
|
|
|
{
|
|
from_node: StringName,
|
|
from_port: int,
|
|
to_node: StringName,
|
|
to_port: int,
|
|
keep_alive: bool
|
|
}
|
|
|
|
例如,可以像这样实现获取在给定鼠标位置处的连接:
|
|
|
|
|
|
.. tabs::
|
|
|
|
.. code-tab:: gdscript
|
|
|
|
var connection = get_closest_connection_at_point(mouse_event.get_position())
|
|
|
|
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_get_connection_count:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`int<class_int>` **get_connection_count**\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GraphEdit_method_get_connection_count>`
|
|
|
|
返回 ``from_node`` 节点的 ``from_port`` 端口的连接数量。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_get_connection_line:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`PackedVector2Array<class_PackedVector2Array>` **get_connection_line**\ (\ from_node\: :ref:`Vector2<class_Vector2>`, to_node\: :ref:`Vector2<class_Vector2>`\ ) |const| :ref:`🔗<class_GraphEdit_method_get_connection_line>`
|
|
|
|
返回构成 ``from_node`` 和 ``to_node`` 之间的连接的点。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_get_connection_list_from_node:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] **get_connection_list_from_node**\ (\ node\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_GraphEdit_method_get_connection_list_from_node>`
|
|
|
|
返回包含 ``node`` 节点所有连接的 :ref:`Array<class_Array>`\ 。
|
|
|
|
连接使用 :ref:`Dictionary<class_Dictionary>` 表示,形式为:
|
|
|
|
::
|
|
|
|
{
|
|
from_node: StringName,
|
|
from_port: int,
|
|
to_node: StringName,
|
|
to_port: int,
|
|
keep_alive: bool
|
|
}
|
|
|
|
\ **示例:**\ 获取指定端口的所有连接:
|
|
|
|
::
|
|
|
|
func get_connection_list_from_port(node, port):
|
|
var connections = get_connection_list_from_node(node)
|
|
var result = []
|
|
for connection in connections:
|
|
var dict = {}
|
|
if connection["from_node"] == node and connection["from_port"] == port:
|
|
dict["node"] = connection["to_node"]
|
|
dict["port"] = connection["to_port"]
|
|
dict["type"] = "left"
|
|
result.push_back(dict)
|
|
elif connection["to_node"] == node and connection["to_port"] == port:
|
|
dict["node"] = connection["from_node"]
|
|
dict["port"] = connection["from_port"]
|
|
dict["type"] = "right"
|
|
result.push_back(dict)
|
|
return result
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_get_connections_intersecting_with_rect:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] **get_connections_intersecting_with_rect**\ (\ rect\: :ref:`Rect2<class_Rect2>`\ ) |const| :ref:`🔗<class_GraphEdit_method_get_connections_intersecting_with_rect>`
|
|
|
|
返回一个 :ref:`Array<class_Array>`\ ,其中包含与给定 :ref:`Rect2<class_Rect2>` 相交的连接列表。
|
|
|
|
连接由 :ref:`Dictionary<class_Dictionary>` 表示,结构如下:
|
|
|
|
::
|
|
|
|
{
|
|
from_node: StringName,
|
|
from_port: int,
|
|
to_node: StringName,
|
|
to_port: int,
|
|
keep_alive: bool
|
|
}
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_get_element_frame:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`GraphFrame<class_GraphFrame>` **get_element_frame**\ (\ element\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_GraphEdit_method_get_element_frame>`
|
|
|
|
返回包含给定名称的 :ref:`GraphElement<class_GraphElement>` 的 :ref:`GraphFrame<class_GraphFrame>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_get_menu_hbox:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`HBoxContainer<class_HBoxContainer>` **get_menu_hbox**\ (\ ) :ref:`🔗<class_GraphEdit_method_get_menu_hbox>`
|
|
|
|
获取包含图形左上角的缩放和网格捕捉控件的 :ref:`HBoxContainer<class_HBoxContainer>`\ 。你可以使用此方法重新定位工具栏或向其添加自定义控件。
|
|
|
|
\ **警告:**\ 这是一个必需的内部节点,删除和释放它可能会导致崩溃。如果你希望隐藏它或其任何子项,请使用它们的 :ref:`CanvasItem.visible<class_CanvasItem_property_visible>` 属性。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_is_node_connected:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **is_node_connected**\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GraphEdit_method_is_node_connected>`
|
|
|
|
如果 ``from_node`` :ref:`GraphNode<class_GraphNode>` 的 ``from_port`` 连接到 ``to_node`` :ref:`GraphNode<class_GraphNode>` 的 ``to_port``\ ,则返回 ``true``\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_is_valid_connection_type:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **is_valid_connection_type**\ (\ from_type\: :ref:`int<class_int>`, to_type\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_GraphEdit_method_is_valid_connection_type>`
|
|
|
|
返回是否可以在两种不同的端口类型之间建立连接。端口类型是使用 :ref:`GraphNode.set_slot()<class_GraphNode_method_set_slot>` 方法为每个插槽的左右端口单独定义的。
|
|
|
|
另见 :ref:`add_valid_connection_type()<class_GraphEdit_method_add_valid_connection_type>` 和 :ref:`remove_valid_connection_type()<class_GraphEdit_method_remove_valid_connection_type>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_remove_valid_connection_type:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **remove_valid_connection_type**\ (\ from_type\: :ref:`int<class_int>`, to_type\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GraphEdit_method_remove_valid_connection_type>`
|
|
|
|
不允许先前由 :ref:`add_valid_connection_type()<class_GraphEdit_method_add_valid_connection_type>` 允许的两种不同端口类型之间的连接。端口类型是通过 :ref:`GraphNode.set_slot()<class_GraphNode_method_set_slot>` 方法为每个插槽的左右端口单独定义的。
|
|
|
|
另见 :ref:`is_valid_connection_type()<class_GraphEdit_method_is_valid_connection_type>`\ 。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_remove_valid_left_disconnect_type:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **remove_valid_left_disconnect_type**\ (\ type\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GraphEdit_method_remove_valid_left_disconnect_type>`
|
|
|
|
Disallows to disconnect nodes when dragging from the left port of the :ref:`GraphNode<class_GraphNode>`'s slot if it has the specified type. Use this to disable a disconnection previously allowed with :ref:`add_valid_left_disconnect_type()<class_GraphEdit_method_add_valid_left_disconnect_type>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_remove_valid_right_disconnect_type:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **remove_valid_right_disconnect_type**\ (\ type\: :ref:`int<class_int>`\ ) :ref:`🔗<class_GraphEdit_method_remove_valid_right_disconnect_type>`
|
|
|
|
Disallows to disconnect nodes when dragging from the right port of the :ref:`GraphNode<class_GraphNode>`'s slot if it has the specified type. Use this to disable a disconnection previously allowed with :ref:`add_valid_right_disconnect_type()<class_GraphEdit_method_add_valid_right_disconnect_type>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_set_connection_activity:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_connection_activity**\ (\ from_node\: :ref:`StringName<class_StringName>`, from_port\: :ref:`int<class_int>`, to_node\: :ref:`StringName<class_StringName>`, to_port\: :ref:`int<class_int>`, amount\: :ref:`float<class_float>`\ ) :ref:`🔗<class_GraphEdit_method_set_connection_activity>`
|
|
|
|
使用 :ref:`activity<class_GraphEdit_theme_color_activity>` 主题属性中提供的颜色,设置 ``from_node`` 的 ``from_port`` 和 ``to_node`` 的 ``to_port`` 之间的连接的颜色。使用 ``amount`` 作为权重,在连接颜色和活动颜色之间线性插值颜色。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_method_set_selected:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_selected**\ (\ node\: :ref:`Node<class_Node>`\ ) :ref:`🔗<class_GraphEdit_method_set_selected>`
|
|
|
|
将指定的 ``node`` 节点设置为选中的节点。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
主题属性说明
|
|
------------
|
|
|
|
.. _class_GraphEdit_theme_color_activity:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Color<class_Color>` **activity** = ``Color(1, 1, 1, 1)`` :ref:`🔗<class_GraphEdit_theme_color_activity>`
|
|
|
|
根据连接的活动值插入连接线的颜色(请参阅 :ref:`set_connection_activity()<class_GraphEdit_method_set_connection_activity>`\ )。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_color_connection_hover_tint_color:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Color<class_Color>` **connection_hover_tint_color** = ``Color(0, 0, 0, 0.3)`` :ref:`🔗<class_GraphEdit_theme_color_connection_hover_tint_color>`
|
|
|
|
当鼠标悬停在连接线上时与该连接线混合的颜色。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_color_connection_rim_color:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Color<class_Color>` **connection_rim_color** = ``Color(0.1, 0.1, 0.1, 0.6)`` :ref:`🔗<class_GraphEdit_theme_color_connection_rim_color>`
|
|
|
|
每条连接线周围的边缘颜色,用于使相交线更容易区分。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_color_connection_valid_target_tint_color:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Color<class_Color>` **connection_valid_target_tint_color** = ``Color(1, 1, 1, 0.4)`` :ref:`🔗<class_GraphEdit_theme_color_connection_valid_target_tint_color>`
|
|
|
|
当前拖动的连接悬停在有效目标端口上时与该连接线混合的颜色。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_color_grid_major:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Color<class_Color>` **grid_major** = ``Color(1, 1, 1, 0.2)`` :ref:`🔗<class_GraphEdit_theme_color_grid_major>`
|
|
|
|
主要栅格线/点的颜色。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_color_grid_minor:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Color<class_Color>` **grid_minor** = ``Color(1, 1, 1, 0.05)`` :ref:`🔗<class_GraphEdit_theme_color_grid_minor>`
|
|
|
|
次要栅格线/点的颜色。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_color_selection_fill:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Color<class_Color>` **selection_fill** = ``Color(1, 1, 1, 0.3)`` :ref:`🔗<class_GraphEdit_theme_color_selection_fill>`
|
|
|
|
选定的矩形的填充颜色。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_color_selection_stroke:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Color<class_Color>` **selection_stroke** = ``Color(1, 1, 1, 0.8)`` :ref:`🔗<class_GraphEdit_theme_color_selection_stroke>`
|
|
|
|
选择的矩形的轮廓颜色。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_constant_connection_hover_thickness:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`int<class_int>` **connection_hover_thickness** = ``0`` :ref:`🔗<class_GraphEdit_theme_constant_connection_hover_thickness>`
|
|
|
|
Widens the line of a connection when the mouse is hovering over it by a percentage factor. A value of ``0`` disables the highlight. A value of ``100`` doubles the line width.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_constant_port_hotzone_inner_extent:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`int<class_int>` **port_hotzone_inner_extent** = ``22`` :ref:`🔗<class_GraphEdit_theme_constant_port_hotzone_inner_extent>`
|
|
|
|
能够抓取端口的(内侧)横向范围。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_constant_port_hotzone_outer_extent:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`int<class_int>` **port_hotzone_outer_extent** = ``26`` :ref:`🔗<class_GraphEdit_theme_constant_port_hotzone_outer_extent>`
|
|
|
|
能够抓取端口的(外侧)横向范围。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_icon_grid_toggle:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Texture2D<class_Texture2D>` **grid_toggle** :ref:`🔗<class_GraphEdit_theme_icon_grid_toggle>`
|
|
|
|
网格开关按钮的图标。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_icon_layout:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Texture2D<class_Texture2D>` **layout** :ref:`🔗<class_GraphEdit_theme_icon_layout>`
|
|
|
|
用于自动排列图形的布局按钮的图标。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_icon_minimap_toggle:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Texture2D<class_Texture2D>` **minimap_toggle** :ref:`🔗<class_GraphEdit_theme_icon_minimap_toggle>`
|
|
|
|
小地图开关按钮的图标。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_icon_snapping_toggle:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Texture2D<class_Texture2D>` **snapping_toggle** :ref:`🔗<class_GraphEdit_theme_icon_snapping_toggle>`
|
|
|
|
吸附开关按钮的图标。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_icon_zoom_in:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Texture2D<class_Texture2D>` **zoom_in** :ref:`🔗<class_GraphEdit_theme_icon_zoom_in>`
|
|
|
|
放大按钮的图标。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_icon_zoom_out:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Texture2D<class_Texture2D>` **zoom_out** :ref:`🔗<class_GraphEdit_theme_icon_zoom_out>`
|
|
|
|
缩小按钮的图标。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_icon_zoom_reset:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`Texture2D<class_Texture2D>` **zoom_reset** :ref:`🔗<class_GraphEdit_theme_icon_zoom_reset>`
|
|
|
|
缩放重置按钮的图标。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_style_menu_panel:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`StyleBox<class_StyleBox>` **menu_panel** :ref:`🔗<class_GraphEdit_theme_style_menu_panel>`
|
|
|
|
.. container:: contribute
|
|
|
|
There is currently no description for this theme property. Please help us by `contributing one <https://contributing.godotengine.org/en/latest/documentation/class_reference.html>`__!
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_style_panel:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`StyleBox<class_StyleBox>` **panel** :ref:`🔗<class_GraphEdit_theme_style_panel>`
|
|
|
|
绘制在栅格下方的背景。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_GraphEdit_theme_style_panel_focus:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`StyleBox<class_StyleBox>` **panel_focus** :ref:`🔗<class_GraphEdit_theme_style_panel_focus>`
|
|
|
|
当 **GraphEdit** 处于聚焦状态时使用的 :ref:`StyleBox<class_StyleBox>`\ (使用辅助应用时)。
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)`
|
|
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
|
.. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)`
|
|
.. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)`
|
|
.. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)`
|
|
.. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)`
|
|
.. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)`
|
|
.. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)`
|
|
.. |void| replace:: :abbr:`void (无返回值。)`
|