Skip to content

Instantly share code, notes, and snippets.

@romgerman
Created December 2, 2025 14:18
Show Gist options
  • Select an option

  • Save romgerman/05b8e23eb8fb38f4dcad8f5acc96525a to your computer and use it in GitHub Desktop.

Select an option

Save romgerman/05b8e23eb8fb38f4dcad8f5acc96525a to your computer and use it in GitHub Desktop.
Godot 4.5.1 editor inspector spacing addon
extends EditorInspectorPlugin
var custom_sb: StyleBoxFlat
func _init() -> void:
custom_sb = StyleBoxFlat.new()
custom_sb.bg_color = Color.TRANSPARENT
custom_sb.corner_radius_top_left = 2
custom_sb.corner_radius_bottom_left = 2
custom_sb.corner_radius_top_right = 2
custom_sb.corner_radius_bottom_right = 2
func _can_handle(object: Object) -> bool:
return true
var category_index: int = 0
var prev_category_index: int = 0
func _parse_category(object: Object, category: String) -> void:
category_index += 1
func _parse_property(
object: Object,
type: Variant.Type,
name: String,
hint_type: PropertyHint,
hint_string: String,
usage_flags: int,
wide: bool
) -> bool:
if category_index != prev_category_index:
var fake_prop_editor = EditorProperty.new()
fake_prop_editor.name = "Fake(EditorProperty)"
fake_prop_editor.visible = false
add_property_editor(
name,
fake_prop_editor,
)
_get_shit_done.call_deferred(fake_prop_editor)
prev_category_index = category_index
return false
func _get_shit_done(prop_editor: EditorProperty) -> void:
var p := prop_editor.get_parent()
while p and p is not VBoxContainer:
p = p.get_parent()
var nodes_to_wrap: Array = []
if p.get_parent().get_class() == "EditorInspectorSection":
p = p.get_parent()
if not p: return
var parent := p.get_parent()
# to top
var index := p.get_index()
while index > 0 and parent.get_child(index).get_class() != "EditorInspectorCategory":
nodes_to_wrap.append(parent.get_child(index))
index -= 1
# append category
var category: Control = parent.get_child(index)
nodes_to_wrap.append(category)
# to bottom
index = p.get_index() + 1
while index < parent.get_child_count() and parent.get_child(index).get_class() != "EditorInspectorCategory":
nodes_to_wrap.push_front(parent.get_child(index))
index += 1
# Styling
if parent is VBoxContainer:
(parent as Control).add_theme_constant_override("separation", 20)
var panel_container := PanelContainer.new()
panel_container.size = p.size
panel_container.add_theme_stylebox_override("panel", custom_sb)
parent.add_child(panel_container)
parent.move_child(panel_container, p.get_index())
var vbox := VBoxContainer.new()
panel_container.add_child(vbox)
nodes_to_wrap.reverse()
for n in nodes_to_wrap:
n.reparent(vbox)
@tool
extends EditorPlugin
const MyEditorInspector := preload("res://addons/editor_ux/editor_inspector.gd")
var inspector_plugin: MyEditorInspector
func _enter_tree() -> void:
inspector_plugin = MyEditorInspector.new()
add_inspector_plugin(inspector_plugin)
func _exit_tree() -> void:
remove_inspector_plugin(inspector_plugin)
inspector_plugin = null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment