godot
godot copied to clipboard
`add_to_end` in `add_property_editor()` appears to do nothing
Tested versions
4.2.2.stable
System information
Godot v4.2.2.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated AMD Radeon RX 7800 XT (Advanced Micro Devices, Inc.; 31.0.24019.1006) - AMD Ryzen 9 7900X 12-Core Processor (24 Threads)
Issue description
I assume the add_to_end property is meant to move properties to the end of the inspector? The docs don't say anything about it. But in my testing the argument does nothing, the editor properties just follow the property order.
Here I've made a custom inspector plugin that accepts all ints and puts in my simple editor that is just a label.
@tool
extends EditorInspectorPlugin
var IntEditor = preload("res://addons/exampleplugin/int_editor.gd")
func _can_handle(object) -> bool:
return true
func _parse_property(object, type, name, hint_type, hint_string, usage_flags, wide) -> bool:
if type == TYPE_INT:
add_property_editor(name, IntEditor.new(), true)
return true
return false
Here is a script where the int is on top.
extends Node2D
@export var int_test := 0
@export var float_test := 0.0
But it doesn't get moved to the end like I expect.
Note: This might just be me misunderstanding what the argument does, but if that's the case, the docs need more info
Steps to reproduce
Try out the MRP project
Minimal reproduction project (MRP)
That's the relevant source code: https://github.com/godotengine/godot/blob/557f63d03796db78255f055b6d06cb5f9195ff7e/editor/editor_inspector.cpp#L3328-L3347
So basically an EditorProperty added with add_to_end = true is ensured to be added after/below any other EditorProperty handling the same property but added with add_to_end = false.
E.g. after changing your EditorInspectorPlugin to always add the default EditorProperty for int (removed return true from _parse_property):
@tool
extends EditorInspectorPlugin
var IntEditor = preload("res://addons/exampleplugin/int_editor.gd")
func _can_handle(object) -> bool:
return true
func _parse_property(object, type, name, hint_type, hint_string, usage_flags, wide) -> bool:
if type == TYPE_INT:
var add_to_end = ...
add_property_editor(name, IntEditor.new(), add_to_end)
return false
Result (v4.2.2.stable.official [15073afe3]):
add_to_end = false |
add_to_end = true |
|---|---|
In the source it's used (only?) by the EditorInspectorPluginTextureRegion for adding the "Edit Region" button: https://github.com/godotengine/godot/blob/557f63d03796db78255f055b6d06cb5f9195ff7e/editor/plugins/texture_region_editor_plugin.cpp#L1269-L1279
So seems like it's just a matter of documenting it? :thinking: