mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-04 10:09:56 +03:00
422 lines
32 KiB
ReStructuredText
422 lines
32 KiB
ReStructuredText
:github_url: hide
|
||
|
||
.. _class_VisualShaderNodeCustom:
|
||
|
||
VisualShaderNodeCustom
|
||
======================
|
||
|
||
**继承:** :ref:`VisualShaderNode<class_VisualShaderNode>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
||
|
||
用于定义自定义 :ref:`VisualShaderNode<class_VisualShaderNode>` 的虚类,以便在可视化着色器编辑器中使用。
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
描述
|
||
----
|
||
|
||
继承这个类可以创建自定义的 :ref:`VisualShader<class_VisualShader>` 脚本扩展,会自动加入到 Visual Shader 编辑器中。\ :ref:`VisualShaderNode<class_VisualShaderNode>` 的行为可以通过覆盖虚方法定义。
|
||
|
||
要让节点注册为编辑器扩展,你必须为你的自定义脚本使用 ``@tool`` 注解并提供 ``class_name``\ 。例如:
|
||
|
||
::
|
||
|
||
@tool
|
||
extends VisualShaderNodeCustom
|
||
class_name VisualShaderNodeNoise
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
教程
|
||
----
|
||
|
||
- :doc:`可视化着色器插件 <../tutorials/plugins/editor/visual_shader_plugins>`
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
方法
|
||
----
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_category<class_VisualShaderNodeCustom_private_method__get_category>`\ (\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_code<class_VisualShaderNodeCustom_private_method__get_code>`\ (\ input_vars\: :ref:`Array<class_Array>`\[:ref:`String<class_String>`\], output_vars\: :ref:`Array<class_Array>`\[:ref:`String<class_String>`\], mode\: :ref:`Mode<enum_Shader_Mode>`, type\: :ref:`Type<enum_VisualShader_Type>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`_get_default_input_port<class_VisualShaderNodeCustom_private_method__get_default_input_port>`\ (\ type\: :ref:`PortType<enum_VisualShaderNode_PortType>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_description<class_VisualShaderNodeCustom_private_method__get_description>`\ (\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_func_code<class_VisualShaderNodeCustom_private_method__get_func_code>`\ (\ mode\: :ref:`Mode<enum_Shader_Mode>`, type\: :ref:`Type<enum_VisualShader_Type>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_global_code<class_VisualShaderNodeCustom_private_method__get_global_code>`\ (\ mode\: :ref:`Mode<enum_Shader_Mode>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`_get_input_port_count<class_VisualShaderNodeCustom_private_method__get_input_port_count>`\ (\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Variant<class_Variant>` | :ref:`_get_input_port_default_value<class_VisualShaderNodeCustom_private_method__get_input_port_default_value>`\ (\ port\: :ref:`int<class_int>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_input_port_name<class_VisualShaderNodeCustom_private_method__get_input_port_name>`\ (\ port\: :ref:`int<class_int>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`PortType<enum_VisualShaderNode_PortType>` | :ref:`_get_input_port_type<class_VisualShaderNodeCustom_private_method__get_input_port_type>`\ (\ port\: :ref:`int<class_int>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_name<class_VisualShaderNodeCustom_private_method__get_name>`\ (\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`_get_output_port_count<class_VisualShaderNodeCustom_private_method__get_output_port_count>`\ (\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_output_port_name<class_VisualShaderNodeCustom_private_method__get_output_port_name>`\ (\ port\: :ref:`int<class_int>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`PortType<enum_VisualShaderNode_PortType>` | :ref:`_get_output_port_type<class_VisualShaderNodeCustom_private_method__get_output_port_type>`\ (\ port\: :ref:`int<class_int>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`_get_property_count<class_VisualShaderNodeCustom_private_method__get_property_count>`\ (\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`_get_property_default_index<class_VisualShaderNodeCustom_private_method__get_property_default_index>`\ (\ index\: :ref:`int<class_int>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_property_name<class_VisualShaderNodeCustom_private_method__get_property_name>`\ (\ index\: :ref:`int<class_int>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`_get_property_options<class_VisualShaderNodeCustom_private_method__get_property_options>`\ (\ index\: :ref:`int<class_int>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`PortType<enum_VisualShaderNode_PortType>` | :ref:`_get_return_icon_type<class_VisualShaderNodeCustom_private_method__get_return_icon_type>`\ (\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`_is_available<class_VisualShaderNodeCustom_private_method__is_available>`\ (\ mode\: :ref:`Mode<enum_Shader_Mode>`, type\: :ref:`Type<enum_VisualShader_Type>`\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`_is_highend<class_VisualShaderNodeCustom_private_method__is_highend>`\ (\ ) |virtual| |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`get_option_index<class_VisualShaderNodeCustom_method_get_option_index>`\ (\ option\: :ref:`int<class_int>`\ ) |const| |
|
||
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
方法说明
|
||
--------
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_category:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_category**\ (\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_category>`
|
||
|
||
覆盖这个方法可以定义 Visual Shader 编辑器的成员对话框中关联的自定义节点的路径。路径类似于 ``"MyGame/MyFunctions/Noise"``\ 。
|
||
|
||
定义这个方法是\ **可选**\ 的。不覆盖时,该节点会被归在“Addons”分类下。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_code:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_code**\ (\ input_vars\: :ref:`Array<class_Array>`\[:ref:`String<class_String>`\], output_vars\: :ref:`Array<class_Array>`\[:ref:`String<class_String>`\], mode\: :ref:`Mode<enum_Shader_Mode>`, type\: :ref:`Type<enum_VisualShader_Type>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_code>`
|
||
|
||
覆盖这个方法可以定义关联的自定义节点的实际着色器代码。着色器代码应该以字符串形式返回,可以包含多行(用 ``"""`` 构造多行字符串比较方便)。
|
||
|
||
\ ``input_vars`` 和 ``output_vars`` 数组包含各个输入和输出变量的字符串名称,这些变量由这个类的 ``_get_input_*`` 和 ``_get_output_*`` 虚方法定义。
|
||
|
||
着色器代码中可以为输出端口赋值。例如 ``return output_vars[0] + " = " + input_vars[0] + ";"``\ 。
|
||
|
||
你可以根据着色器模式 ``mode`` 和/或类型 ``type`` 自定义生成的代码。
|
||
|
||
\ **必须**\ 定义这个方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_default_input_port:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **_get_default_input_port**\ (\ type\: :ref:`PortType<enum_VisualShaderNode_PortType>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_default_input_port>`
|
||
|
||
覆盖该方法来定义当由于将连接从已有节点拖动到图形上的空白区域而创建节点时应默认连接的输入端口。
|
||
|
||
定义这个方法是\ **可选的**\ ,如果未被覆盖,将创建到第一个有效端口的连接。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_description:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_description**\ (\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_description>`
|
||
|
||
覆盖这个方法可以定义可视化着色器编辑器的成员对话框中的相关自定义节点的描述。
|
||
|
||
定义这个方法是\ **可选**\ 的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_func_code:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_func_code**\ (\ mode\: :ref:`Mode<enum_Shader_Mode>`, type\: :ref:`Type<enum_VisualShader_Type>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_func_code>`
|
||
|
||
覆盖这个方法可以在每个着色器函数的开头添加着色器代码(单次)。着色器代码应该以字符串形式返回,可以包含多行(用 ``"""`` 构造多行字符串比较方便)。
|
||
|
||
如果有多个不同类型的自定义节点同时使用这个特性,则插入的顺序是未定义的。
|
||
|
||
你可以根据着色器模式 ``mode`` 和/或类型 ``type`` 自定义生成的代码。
|
||
|
||
定义这个方法是\ **可选**\ 的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_global_code:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_global_code**\ (\ mode\: :ref:`Mode<enum_Shader_Mode>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_global_code>`
|
||
|
||
覆盖这个方法可以在全局着色器的开头添加着色器代码,定义你自己的标准库,提供可复用的方法、varying、常量、uniform 等内容。着色器代码应该以字符串形式返回,可以包含多行(用 ``"""`` 构造多行字符串比较方便)。
|
||
|
||
使用这个功能时请小心,因为可能造成与其他自定义节点的命名冲突,所以请务必为定义的实体提供唯一名称。
|
||
|
||
你可以根据着色器模式 ``mode`` 自定义生成的代码。
|
||
|
||
定义这个方法是\ **可选**\ 的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_input_port_count:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **_get_input_port_count**\ (\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_input_port_count>`
|
||
|
||
覆盖该方法以定义关联的自定义节点的输入端口数。
|
||
|
||
定义该方法是\ **必需的**\ 。如果没有被覆盖,则该节点没有输入端口。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_input_port_default_value:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Variant<class_Variant>` **_get_input_port_default_value**\ (\ port\: :ref:`int<class_int>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_input_port_default_value>`
|
||
|
||
覆盖该方法可以定义指定输入端口的默认值。优先使用该方法而不是 :ref:`VisualShaderNode.set_input_port_default_value()<class_VisualShaderNode_method_set_input_port_default_value>`\ 。
|
||
|
||
定义该方法是\ **必需的**\ 。如果没有被覆盖,则该节点的输入端口没有默认值。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_input_port_name:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_input_port_name**\ (\ port\: :ref:`int<class_int>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_input_port_name>`
|
||
|
||
覆盖此方法来定义相关自定义节点的输入端口的名称。这些名称既用于编辑器中的输入槽,也作为着色器代码中的标识符,并在\ :ref:`_get_code()<class_VisualShaderNodeCustom_private_method__get_code>`\ 中的\ ``input_vars``\ 数组中传递。
|
||
|
||
定义这个方法是\ **可选的**\ ,但推荐使用。如果没有被覆盖,输入端口被命名为\ ``"in"+str(port)``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_input_port_type:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`PortType<enum_VisualShaderNode_PortType>` **_get_input_port_type**\ (\ port\: :ref:`int<class_int>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_input_port_type>`
|
||
|
||
覆盖此方法以定义相关自定义节点的每个输入端口的返回类型。
|
||
|
||
定义这个方法是\ **可选的**\ ,但推荐使用。如果没有被覆盖,输入端口将返回 :ref:`VisualShaderNode.PORT_TYPE_SCALAR<class_VisualShaderNode_constant_PORT_TYPE_SCALAR>` 类型。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_name:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_name**\ (\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_name>`
|
||
|
||
覆盖此方法来定义可视化着色器编辑器的成员对话框和图中的相关自定义节点的名称。
|
||
|
||
定义这个方法是\ **可选的**\ ,但推荐使用。如果不覆盖,节点将被命名为 "Unnamed"。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_output_port_count:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **_get_output_port_count**\ (\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_output_port_count>`
|
||
|
||
覆盖该方法以定义关联的自定义节点的输出端口数。
|
||
|
||
定义该方法是\ **必需的**\ 。如果没有被覆盖,则该节点没有输出端口。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_output_port_name:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_output_port_name**\ (\ port\: :ref:`int<class_int>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_output_port_name>`
|
||
|
||
覆盖此方法来定义相关自定义节点的输出端口的名称。这些名字既用于编辑器中的输出槽,也作为着色器代码中的标识符,并在\ :ref:`_get_code()<class_VisualShaderNodeCustom_private_method__get_code>`\ 中的\ ``output_vars``\ 数组中传递。
|
||
|
||
定义这个方法是\ **可选的**\ ,但推荐使用。如果没有被覆盖,输出端口被命名为\ ``"out" + str(port)``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_output_port_type:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`PortType<enum_VisualShaderNode_PortType>` **_get_output_port_type**\ (\ port\: :ref:`int<class_int>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_output_port_type>`
|
||
|
||
覆盖此方法以定义相关自定义节点的每个输出端口的返回类型。
|
||
|
||
定义这个方法是\ **可选的**\ ,但推荐使用。如果没有被覆盖,输出端口将返回\ :ref:`VisualShaderNode.PORT_TYPE_SCALAR<class_VisualShaderNode_constant_PORT_TYPE_SCALAR>`\ 类型。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_property_count:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **_get_property_count**\ (\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_property_count>`
|
||
|
||
覆盖这个方法来定义属性的数量。
|
||
|
||
定义这个方法是\ **可选**\ 的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_property_default_index:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **_get_property_default_index**\ (\ index\: :ref:`int<class_int>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_property_default_index>`
|
||
|
||
覆盖这个方法可以定义关联的自定义节点的属性的默认索引。
|
||
|
||
定义这个方法是\ **可选**\ 的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_property_name:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_property_name**\ (\ index\: :ref:`int<class_int>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_property_name>`
|
||
|
||
覆盖这个方法可以定义关联的自定义节点的属性的名称。
|
||
|
||
定义这个方法是\ **可选**\ 的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_property_options:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`PackedStringArray<class_PackedStringArray>` **_get_property_options**\ (\ index\: :ref:`int<class_int>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_property_options>`
|
||
|
||
覆盖这个方法可以定义关联的自定义节点的下拉列表属性内的选项。
|
||
|
||
定义这个方法是\ **可选**\ 的。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__get_return_icon_type:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`PortType<enum_VisualShaderNode_PortType>` **_get_return_icon_type**\ (\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__get_return_icon_type>`
|
||
|
||
覆盖此方法来定义可视化着色器编辑器的成员对话框中相关自定义节点的返回图标。
|
||
|
||
定义这个方法是\ **可选的**\ 。如果不覆盖,就不会显示返回图标。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__is_available:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **_is_available**\ (\ mode\: :ref:`Mode<enum_Shader_Mode>`, type\: :ref:`Type<enum_VisualShader_Type>`\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__is_available>`
|
||
|
||
覆盖这个方法可以防止该节点出现在特定模式 ``mode`` 和/或类型 ``type`` 的成员对话框中。
|
||
|
||
定义这个方法是\ **可选**\ 的。未覆盖时为 ``true``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_private_method__is_highend:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **_is_highend**\ (\ ) |virtual| |const| :ref:`🔗<class_VisualShaderNodeCustom_private_method__is_highend>`
|
||
|
||
Override this method to enable the high-end mark in the Visual Shader Editor's members dialog. This should return ``true`` for nodes that only work when using the Forward+ and Mobile renderers.
|
||
|
||
Defining this method is **optional**. If not overridden, it's ``false``, which indicates this node works with all renderers (including Compatibility).
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_VisualShaderNodeCustom_method_get_option_index:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **get_option_index**\ (\ option\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_VisualShaderNodeCustom_method_get_option_index>`
|
||
|
||
返回图表中下拉列表选项的选定索引。你可以使用该函数来定义 :ref:`_get_code()<class_VisualShaderNodeCustom_private_method__get_code>` 或 :ref:`_get_global_code()<class_VisualShaderNodeCustom_private_method__get_global_code>` 中的特定行为。
|
||
|
||
.. |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 (无返回值。)`
|