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.
Checking the stable version of the documentation...
EditorInspectorPlugin
繼承: RefCounted < Object
在屬性檢視器中新增自訂屬性編輯器的外掛程式。
說明
EditorInspectorPlugin 允許為 EditorInspector 新增自訂屬性編輯器。
當物件被編輯時,_can_handle() 方法會被呼叫,如果物件類型被支援,則必須傳回 true。
如果被支援,_parse_begin() 方法將會被呼叫,允許在類別的開頭放置自訂 Control。
隨後,對於每個類別和屬性,都會呼叫 _parse_category() 和 _parse_property()。它們也提供新增自訂 Control 到屬性檢視器的能力。
最後,將會呼叫 _parse_end()。
在每次呼叫這些方法時,「add」方法可以被呼叫。
若要使用 EditorInspectorPlugin,請首先使用 EditorPlugin.add_inspector_plugin() 方法註冊它。
教學
方法
_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 |
_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 = "") 🔗
為單個屬性新增屬性編輯器。editor 控制項必須繼承自 EditorProperty。
同一個屬性可以有多個屬性編輯器。如果 add_to_end 為 true 新新增的編輯器會顯示在該屬性所有 add_to_end 為 false 的編輯器之後。例如,Sprite2D.region_rect 普通 Rect2 編輯器下面的“編輯區域”按鈕就是使用這個參數新增的。
可以使用 label 選擇該屬性編輯器在屬性檢視器中的自訂標籤。留空時則會根據屬性的名稱來計算標籤。
void add_property_editor_for_multiple_properties(label: String, properties: PackedStringArray, editor: Control) 🔗
新增能夠修改多個屬性的編輯器。editor 控制項必須擴充 EditorProperty。