How to correctly use control in EditorInspectorPlugin

Godot Version

4.5

Question

I’m building a plugin to create a custom tilemap solution. I need some complex editors but the functionality that EditorInspectorPlugin gives doesn’t seem enough. So I created a .tscn with my UI (this is not all, just a test) and used EditorInspectorPlugin.add_custom_control method. At first it looked bad, overlapping other editors. When I forced a minimum size on the root control, it got better, but still wrong because it renders above and not below the “TileRelationRule” label, also, I’m setting manually custom size, which is error prone when I add more stuff to that scene. Am I doing something wrong here? This is my first Godot plugin and I read all the docs I found. Images:

EditorInpsectorPlugin code:

extends EditorInspectorPlugin

func _can_handle(object):
	return object is TileRelationRule

func _parse_begin(object):
	var panel_scene = preload("res://addons/teragrid/scenes/ui/rule_tile_panel.tscn")
	var panel = panel_scene.instantiate()

	# This for later
	if panel.has_method("set_rule"):
		panel.set_rule(object)

	add_custom_control(panel)

func _parse_property(object, type, name, hint, hint_text, usage, wide):
	if name in ["below", "adjacent", "above"]:
		return true # Godot doesn't draw it

	return false

The resource script

class_name TileRelationRule extends Resource

enum TileState {
	ANY = 0,      
	REQUIRE = 1,  
	FORBID = 2,   
}

enum Layer { BELOW, ADJACENT, ABOVE }
enum Direction {
	NW, N, NE,
	W,  C, E,
	SW, S, SE
}

@export var below := PackedByteArray([0, 0, 0])
@export var adjacent := PackedByteArray([0, 0, 0])
@export var above := PackedByteArray([0, 0, 0])

It renders above because you are adding it in the EditorInspectorPlugin._parse_begin() method. Try to add it in the EditorInspectorPlugin._parse_category() method instead.

Thank you! I still didn’t get it right because I have to make that run only for one of the categories, but I’ve also noticed I’m doing some other things wrong while doing this. With this answer I can continue forward.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.