Attention: Here be dragons

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

EditorInspectorPlugin

繼承: RefCounted < Object

在屬性檢視器中新增自訂屬性編輯器的外掛程式。

說明

EditorInspectorPlugin 允許為 EditorInspector 新增自訂屬性編輯器。

當物件被編輯時,_can_handle() 方法會被呼叫,如果物件類型被支援,則必須傳回 true

如果被支援,_parse_begin() 方法將會被呼叫,允許在類別的開頭放置自訂 Control。

隨後,對於每個類別和屬性,都會呼叫 _parse_category()_parse_property()。它們也提供新增自訂 Control 到屬性檢視器的能力。

最後,將會呼叫 _parse_end()

在每次呼叫這些方法時,「add」方法可以被呼叫。

若要使用 EditorInspectorPlugin,請首先使用 EditorPlugin.add_inspector_plugin() 方法註冊它。

教學

方法

bool

_can_handle(object: Object) virtual const

void

_parse_begin(object: Object) virtual

void

_parse_category(object: Object, category: String) virtual

void

_parse_end(object: Object) virtual

void

_parse_group(object: Object, group: String) virtual

bool

_parse_property(object: Object, type: Variant.Type, name: String, hint_type: PropertyHint, hint_string: String, usage_flags: BitField[PropertyUsageFlags], wide: bool) virtual

void

add_custom_control(control: Control)

void

add_property_editor(property: String, editor: Control, add_to_end: bool = false, label: String = "")

void

add_property_editor_for_multiple_properties(label: String, properties: PackedStringArray, editor: Control)


方法說明

bool _can_handle(object: Object) virtual const 🔗

如果此外掛程式可以處理此物件返回 true


void _parse_begin(object: Object) virtual 🔗

可以將控制項新增在 object 的屬性列表開頭時呼叫。


void _parse_category(object: Object, category: String) virtual 🔗

可以將控制項新增在 object 屬性列表中的某個分類開頭時呼叫。


void _parse_end(object: Object) virtual 🔗

可以將控制項新增在 object 的屬性列表末尾時呼叫。


void _parse_group(object: Object, group: String) virtual 🔗

可以將控制項新增在 object 屬性列表的某個群組或子群組的開頭時呼叫。


bool _parse_property(object: Object, type: Variant.Type, name: String, hint_type: PropertyHint, hint_string: String, usage_flags: BitField[PropertyUsageFlags], wide: bool) virtual 🔗

可以為 object 的屬性列表新增針對屬性的編輯器時呼叫。這些編輯器必須繼承 EditorProperty。返回 true 會移除該屬性的內建編輯器,否則會在內建編輯器之前插入自訂編輯器。


void add_custom_control(control: Control) 🔗

新增自訂控制項,它不一定是屬性編輯器。


void add_property_editor(property: String, editor: Control, add_to_end: bool = false, label: String = "") 🔗

Adds a property editor for an individual property. The editor control must extend EditorProperty.

There can be multiple property editors for a property. If add_to_end is true, this newly added editor will be displayed after all the other editors of the property whose add_to_end is false. For example, the editor uses this parameter to add an "Edit Region" button for Sprite2D.region_rect below the regular Rect2 editor.

label can be used to choose a custom label for the property editor in the inspector. If left empty, the label is computed from the name of the property instead.


void add_property_editor_for_multiple_properties(label: String, properties: PackedStringArray, editor: Control) 🔗

新增能夠修改多個屬性的編輯器。editor 控制項必須擴充 EditorProperty