:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/EditorProperty.xml. .. _class_EditorProperty: EditorProperty ============== **继承:** :ref:`Container` **<** :ref:`Control` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` 用于编辑属性的自定义控件,可以添加到 :ref:`EditorInspector` 中。 .. rst-class:: classref-introduction-group 描述 ---- 用于编辑属性的自定义控件,可以添加到 :ref:`EditorInspector` 中。通过 :ref:`EditorInspectorPlugin` 添加。 .. rst-class:: classref-reftable-group 属性 ---- .. table:: :widths: auto +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`checkable` | ``false`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`checked` | ``false`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`deletable` | ``false`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`draw_background` | ``true`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`draw_label` | ``true`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`draw_warning` | ``false`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`FocusMode` | focus_mode | ``3`` (overrides :ref:`Control`) | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`keying` | ``false`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`String` | :ref:`label` | ``""`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`float` | :ref:`name_split_ratio` | ``0.5`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`read_only` | ``false`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`selectable` | ``true`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ | :ref:`bool` | :ref:`use_folding` | ``false`` | +------------------------------------------+-------------------------------------------------------------------------+---------------------------------------------------------------------+ .. rst-class:: classref-reftable-group 方法 ---- .. table:: :widths: auto +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_set_read_only`\ (\ read_only\: :ref:`bool`\ ) |virtual| | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_update_property`\ (\ ) |virtual| | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_focusable`\ (\ control\: :ref:`Control`\ ) | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`deselect`\ (\ ) | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`emit_changed`\ (\ property\: :ref:`StringName`, value\: :ref:`Variant`, field\: :ref:`StringName` = &"", changing\: :ref:`bool` = false\ ) | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Object` | :ref:`get_edited_object`\ (\ ) | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`get_edited_property`\ (\ ) |const| | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_selected`\ (\ ) |const| | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`select`\ (\ focusable\: :ref:`int` = -1\ ) | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_bottom_editor`\ (\ editor\: :ref:`Control`\ ) | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_label_reference`\ (\ control\: :ref:`Control`\ ) | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_object_and_property`\ (\ object\: :ref:`Object`, property\: :ref:`StringName`\ ) | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`update_property`\ (\ ) | +-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 信号 ---- .. _class_EditorProperty_signal_multiple_properties_changed: .. rst-class:: classref-signal **multiple_properties_changed**\ (\ properties\: :ref:`PackedStringArray`, value\: :ref:`Array`\ ) :ref:`🔗` 如果想要同时修改多个属性,请发出它。如果属性是通过 :ref:`EditorInspectorPlugin._parse_property()` 添加的,请勿使用。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_object_id_selected: .. rst-class:: classref-signal **object_id_selected**\ (\ property\: :ref:`StringName`, id\: :ref:`int`\ ) :ref:`🔗` 子检查器会使用。如果选择的是对象 ID,则触发。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_property_can_revert_changed: .. rst-class:: classref-signal **property_can_revert_changed**\ (\ property\: :ref:`StringName`, can_revert\: :ref:`bool`\ ) :ref:`🔗` 当属性的可恢复性(即,它是否具有非默认值并因此显示为带有恢复图标)发生变化时发出。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_property_changed: .. rst-class:: classref-signal **property_changed**\ (\ property\: :ref:`StringName`, value\: :ref:`Variant`, field\: :ref:`StringName`, changing\: :ref:`bool`\ ) :ref:`🔗` 不要手动触发,使用 :ref:`emit_changed()` 方法代替。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_property_checked: .. rst-class:: classref-signal **property_checked**\ (\ property\: :ref:`StringName`, checked\: :ref:`bool`\ ) :ref:`🔗` 勾选某个属性时发出。内部使用。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_property_deleted: .. rst-class:: classref-signal **property_deleted**\ (\ property\: :ref:`StringName`\ ) :ref:`🔗` 删除某个属性时发出。内部使用。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_property_favorited: .. rst-class:: classref-signal **property_favorited**\ (\ property\: :ref:`StringName`, favorited\: :ref:`bool`\ ) :ref:`🔗` 请在想要将属性标记为收藏时发出,会让属性显示在检查器开头。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_property_keyed: .. rst-class:: classref-signal **property_keyed**\ (\ property\: :ref:`StringName`\ ) :ref:`🔗` 请在想要将这个值添加为动画关键帧时发出(请先检查是否启用了键控)。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_property_keyed_with_value: .. rst-class:: classref-signal **property_keyed_with_value**\ (\ property\: :ref:`StringName`, value\: :ref:`Variant`\ ) :ref:`🔗` 请在想用单个值为属性设置关键帧时发出。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_property_overridden: .. rst-class:: classref-signal **property_overridden**\ (\ ) :ref:`🔗` 请求对当前项目的设置进行覆盖时发出。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_property_pinned: .. rst-class:: classref-signal **property_pinned**\ (\ property\: :ref:`StringName`, pinned\: :ref:`bool`\ ) :ref:`🔗` 如果想要对某个属性进行标记(或者取消标记),让它无论是否与默认值相等都进行保存,请发出它。 默认值指节点刚刚实例化后属性的取值,可以来自继承/实例化链上的祖先场景、脚本或内置类。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_resource_selected: .. rst-class:: classref-signal **resource_selected**\ (\ path\: :ref:`String`, resource\: :ref:`Resource`\ ) :ref:`🔗` 如果你想编辑一个子资源,请将此信号与资源一起发出。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_signal_selected: .. rst-class:: classref-signal **selected**\ (\ path\: :ref:`String`, focusable_idx\: :ref:`int`\ ) :ref:`🔗` 选择时触发。内部使用。 .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 属性说明 -------- .. _class_EditorProperty_property_checkable: .. rst-class:: classref-property :ref:`bool` **checkable** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_checkable**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_checkable**\ (\ ) 用于检查器,该属性可勾选时设置为 ``true``\ 。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_property_checked: .. rst-class:: classref-property :ref:`bool` **checked** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_checked**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_checked**\ (\ ) 用于检查器,该属性已勾选时设置为 ``true``\ 。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_property_deletable: .. rst-class:: classref-property :ref:`bool` **deletable** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_deletable**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_deletable**\ (\ ) 用于检查器,该属性可以被用户删除时设置为 ``true``\ 。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_property_draw_background: .. rst-class:: classref-property :ref:`bool` **draw_background** = ``true`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_draw_background**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_draw_background**\ (\ ) 用于检查器,该属性绘制背景时设置为 ``true``\ 。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_property_draw_label: .. rst-class:: classref-property :ref:`bool` **draw_label** = ``true`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_draw_label**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_draw_label**\ (\ ) 用于检查器,该属性绘制标签时设置为 ``true``\ 。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_property_draw_warning: .. rst-class:: classref-property :ref:`bool` **draw_warning** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_draw_warning**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_draw_warning**\ (\ ) 用于检查器,该属性用编辑器主题的警告色绘制时设置为 ``true``\ 。用于可编辑子节点的属性。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_property_keying: .. rst-class:: classref-property :ref:`bool` **keying** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_keying**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_keying**\ (\ ) 用于检查器,该属性可以被添加为动画关键帧时设置为 ``true``\ 。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_property_label: .. rst-class:: classref-property :ref:`String` **label** = ``""`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_label**\ (\ value\: :ref:`String`\ ) - :ref:`String` **get_label**\ (\ ) 设置此属性可改变标签(如果你想显示标签)。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_property_name_split_ratio: .. rst-class:: classref-property :ref:`float` **name_split_ratio** = ``0.5`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_name_split_ratio**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_name_split_ratio**\ (\ ) 标签和编辑框之间的空间占比。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_property_read_only: .. rst-class:: classref-property :ref:`bool` **read_only** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_read_only**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_read_only**\ (\ ) 用于检查器,该属性为只读时设置为 ``true``\ 。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_property_selectable: .. rst-class:: classref-property :ref:`bool` **selectable** = ``true`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_selectable**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_selectable**\ (\ ) 用于检查器,该属性可选中时设置为 ``true``\ 。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_property_use_folding: .. rst-class:: classref-property :ref:`bool` **use_folding** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_use_folding**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_using_folding**\ (\ ) 用于检查器,该属性使用折叠时设置为 ``true``\ 。 .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 方法说明 -------- .. _class_EditorProperty_private_method__set_read_only: .. rst-class:: classref-method |void| **_set_read_only**\ (\ read_only\: :ref:`bool`\ ) |virtual| :ref:`🔗` 当属性的只读状态被改变时被调用。它可用于将自定义控件改变为只读或可修改的状态。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_private_method__update_property: .. rst-class:: classref-method |void| **_update_property**\ (\ ) |virtual| :ref:`🔗` 当这个虚函数被调用时,你必须更新你的编辑器。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_method_add_focusable: .. rst-class:: classref-method |void| **add_focusable**\ (\ control\: :ref:`Control`\ ) :ref:`🔗` 如果添加的任何控件可以获得键盘焦点,将其添加到此处。这样可以确保在检查器被刷新时恢复焦点。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_method_deselect: .. rst-class:: classref-method |void| **deselect**\ (\ ) :ref:`🔗` 以未选中的形式绘制属性。由检查器使用。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_method_emit_changed: .. rst-class:: classref-method |void| **emit_changed**\ (\ property\: :ref:`StringName`, value\: :ref:`Variant`, field\: :ref:`StringName` = &"", changing\: :ref:`bool` = false\ ) :ref:`🔗` 如果一个或几个属性发生了变化,必然会调用这个函数。\ ``field`` 用于你的编辑器可以单独修改字段的情况(例如,Vector3.x)。\ ``changing`` 参数可以避免编辑器请求刷新该属性(如果不确定,请保留为 ``false``\ )。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_method_get_edited_object: .. rst-class:: classref-method :ref:`Object` **get_edited_object**\ (\ ) :ref:`🔗` 返回编辑的对象。 \ **注意:**\ 如果编辑器尚未与属性关联则会返回 ``null``\ 。不过能够\ *保证*\ 在 :ref:`_update_property()` 和 :ref:`_set_read_only()` 中该值非 ``null``\ 。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_method_get_edited_property: .. rst-class:: classref-method :ref:`StringName` **get_edited_property**\ (\ ) |const| :ref:`🔗` 返回编辑的属性。如果你的编辑器适用于单个属性(通过 :ref:`EditorInspectorPlugin._parse_property()` 添加),那么就会返回该属性。 \ **注意:**\ 如果编辑器尚未与属性关联则会返回 ``null``\ 。不过能够\ *保证*\ 在 :ref:`_update_property()` 和 :ref:`_set_read_only()` 中该值非 ``null``\ 。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_method_is_selected: .. rst-class:: classref-method :ref:`bool` **is_selected**\ (\ ) |const| :ref:`🔗` 如果属性以未选中的形式绘制,则返回 ``true``\ 。由检查器使用。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_method_select: .. rst-class:: classref-method |void| **select**\ (\ focusable\: :ref:`int` = -1\ ) :ref:`🔗` 以选中的形式绘制属性。由检查器使用。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_method_set_bottom_editor: .. rst-class:: classref-method |void| **set_bottom_editor**\ (\ editor\: :ref:`Control`\ ) :ref:`🔗` 将 ``editor`` 控件放在属性标签的下方。该控件必须事先用 :ref:`Node.add_child()` 添加。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_method_set_label_reference: .. rst-class:: classref-method |void| **set_label_reference**\ (\ control\: :ref:`Control`\ ) :ref:`🔗` 由检查器使用,设为计算标签大小时用作参考的控件。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_method_set_object_and_property: .. rst-class:: classref-method |void| **set_object_and_property**\ (\ object\: :ref:`Object`, property\: :ref:`StringName`\ ) :ref:`🔗` 分配要编辑的对象和属性。 .. rst-class:: classref-item-separator ---- .. _class_EditorProperty_method_update_property: .. rst-class:: classref-method |void| **update_property**\ (\ ) :ref:`🔗` 强制刷新属性显示。 .. |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 (无返回值。)`