Makes it easier to add custom inspector controls to nodes.
Download the project and copy the addon folder into your godot project.
Go to Project Settings > Plugins, and enable Extendable Inspector.
Let's add a button that prints the node name in godot's output:
- Choose the node that should have this control, make sure its script has the
@tool
annotation at the beginning, this allows it to run code while in the editor. - Define a method called
_extend_inspector_begin
that receives a parameter, let's call that parameterinspector
. If you want, you can type it asExtendableInspector
to get some autocomplete features: - Create a button that when pressed, it prints the node's name. Then, simply add it to the inspector with
inspector.add_custom_control(a_control)
. You will have to unfocus the node and focus it again for the button to appear:
Here's the entire code in case you want to try it out:
@tool
extends Node2D
func _extend_inspector_begin(inspector: ExtendableInspector):
var button = Button.new()
button.text = "Say your name"
button.pressed.connect(func(): print(self.name))
inspector.add_custom_control(button)
What this plugin does is allow extending the inspector by declaring some methods in the script for which you want to add custom extensions to the inspector.
The supported methods are analogous to methods that can be defined in an EditorInspectorPlugin
to add new features to the inspector.
https://docs.godotengine.org/en/latest/classes/class_editorinspectorplugin.html#class-editorinspectorplugin-method-add-property-editor-for-multiple-properties
These methods are:
void _extend_inspector_begin(inspector: ExtendableInspector)
Allows adding controls at the beginning of the inspector.
void _extend_inspector_end(inspector: ExtendableInspector)
Allows adding controls at the end of the inspector.
bool _extend_inspector_category(inspector: ExtendableInspector, category: String)
Allows adding controls at the beginning of a category in the property list for object.
void _extend_inspector_property(inspector: ExtendableInspector, object: Object, type: int, name: String, hint_type: int, hint_string: String, usage_flags: int, wide: bool)
Allows adding property-specific editors to the property list for object. The added editor control must extend EditorProperty
. Returning true
removes the built-in editor for this property, otherwise allows to insert a custom editor before the built-in one.
Examples can be found in the example folder
This plugin has a core folder that adds the functionality to let you extend the inspector with any custom control you define from your own scripts.
Apart from that, there's a utils
folder that defines some already made controls that can be added to the inspector.