Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

EditorInspectorPlugin

继承: RefCounted < Object

插件,用于在检查器上添加自定义属性编辑器。

描述

EditorInspectorPlugin 允许将自定义属性编辑器添加到 EditorInspector

当编辑对象时,会调用 _can_handle 函数,如果支持该对象类型,则必须返回 true

如果支持,函数 _parse_begin 将被调用,允许在类的开头放置自定义控件。

随后,为每个类别和属性调用 _parse_category_parse_property。它们也提供了向检查器添加自定义控件的能力。

最后,将调用 _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, String category ) virtual

void

_parse_end ( Object object ) virtual

void

_parse_group ( Object object, String group ) virtual

bool

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

void

add_custom_control ( Control control )

void

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

void

add_property_editor_for_multiple_properties ( String label, PackedStringArray properties, Control editor )


方法说明

bool _can_handle ( Object object ) virtual const

如果此插件可以处理此对象返回 true


void _parse_begin ( Object object ) virtual

可以将控件添加在 object 的属性列表开头时调用。


void _parse_category ( Object object, String category ) virtual

可以将控件添加在 object 属性列表中的某个分类开头时调用。


void _parse_end ( Object object ) virtual

可以将控件添加在 object 的属性列表末尾时调用。


void _parse_group ( Object object, String group ) virtual

可以将控件添加在 object 属性列表的某个分组或子分组的开头时调用。


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

可以为 object 的属性列表添加针对属性的编辑器时调用。这些编辑器必须继承 EditorProperty。返回 true 会移除该属性的内置编辑器,否则会在内置编辑器之前插入自定义编辑器。


void add_custom_control ( Control control )

添加自定义控件,它不一定是属性编辑器。


void add_property_editor ( String property, Control editor, bool add_to_end=false )

为单独的属性添加属性编辑器。editor 控件必须扩展 EditorProperty


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

添加能够修改多个属性的编辑器。editor 控件必须扩展 EditorProperty