Godot version: 3.1 Beta 10 e930fb9
OS/device including version: OSX Mojave 10.14.3
TL;DR. Can anyone provide an example of using EditorInspectorPlugin
and EdtiorProperty
to implement custom inspector?
I'm was trying to implement a custom editor inspector for a custom resource class, in which one exported
property depends on another. Goal is to modify the inspector for this resource to display the dependent property as read-only and to update it's value whenever the value of another property has changed.
I have tried to use combination of EditorInspectorPlugin
and EditorProperty
to achieve this. But I found out that none of the EditorProperty
signals (e.g. property_changed ( String property, Nil value)
and others) actually get fired. In addition none of the properties like read-only
seem to work either.
Am I missing something? Or are these features not fully implemented yet?
An example code I have tried to implement:
# CustomResource.gd
extends Resource
class_name CustomResource
export (int, 1, 100) var agility = 1
export (int) var speed = 2 * agility
# custom_editor.gd
tool
extends EditorPlugin
const CustomInpsectorPlugin = preload("res://addons/custom_editor/CustomInpsectorPlugin.gd")
var plugin
func _enter_tree():
plugin = CustomInpsectorPlugin.new()
add_inspector_plugin(plugin)
func _exit_tree():
remove_inspector_plugin(plugin)
plugin.free()
# CutomInspectorPlugin.gd
tool
extends EditorInspectorPlugin
func parse_begin (object):
agilityControl = EditorProperty.new()
agilityControl.read_only = true # this doesn't have any effect
agilityControl.connect("property_changed", self, "_on_property_changed")
add_property_editor("agility", agilityControl)
func can_handle (object):
if object is CustomResource:
return true
return false
func _on_property_changed(property, value):
# This function is never called
print("on property changed: ", property, ", ", value)