Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditorInspectorPlugin not parsing custom category #87910

Closed
rbarongr opened this issue Feb 3, 2024 · 1 comment · Fixed by #87915
Closed

EditorInspectorPlugin not parsing custom category #87910

rbarongr opened this issue Feb 3, 2024 · 1 comment · Fixed by #87915

Comments

@rbarongr
Copy link

rbarongr commented Feb 3, 2024

Tested versions

  • Reproducible in: v4.2.1.stable.official [b09f793], v4.3.dev2.official [3524346]
  • Not reproducible in: v4.1.3.stable.official

System information

Godot v4.2.1.stable - Windows 10.0.22631

Issue description

When creating a plugin for Godot I'm adding a custom button to the editor interface to do something when pressed.

I add this button to a custom category for a specific custom Class. This way I can put the button in the editor interface where I want it to be.

I started the plugin in Godot v4.1, and now when I try to use it in Godot v4.2, the button is not showing. I found out that the button was not showing because I was using @export_category.

In the MRP you can find the button in the editor interface as expected in v4.1:

EditorInspectorPluginCustomCategoryIssue413

But in v4.2.1, the button is not showing:

EditorInspectorPluginCustomCategoryIssue421

This is still happening in Godot v4.3-dev2.

The Custom Node script is just this:

class_name CustomNode extends Node

@export var a_variable: String
@export_category("Category")
@export var another_variable: String

And the EditorPlugin code is just this:

@tool
extends EditorPlugin

var plugin

func _enter_tree():
	plugin = preload("res://addons/myinspectorplugin/my_inspector_plugin.gd").new()
	add_inspector_plugin(plugin)

func _exit_tree():
	remove_inspector_plugin(plugin)

The problem seems to be that the _parse_category() of EditorInspectorPlugin is not parsing custom categories from scripts.

Steps to reproduce

  1. Open the MRP. (It's built in v4.2.1 so if you open it with v.4.1.3 it will show that it needs to be modified, it doesn't matter. You can just click OK).
  2. Open the custom_node.tscn.
  3. Click the CustomNode in the scene tree.
  4. Look at the inspector

In Godot v4.1.3, a button with the name MyCustomCategoryButton will appear as expected.
In Godot v4.2.1, that button will not be showing.

Minimal reproduction project (MRP)

EditorInspectorPluginCustomCategoryIssue421.zip

@kleonc
Copy link
Member

kleonc commented Feb 3, 2024

Happens since v4.2.dev4.official [549fcce].
Regression from #81221, cc @dalexeev.

Specifically this makes the custom category be skipped:

// `hint_script` should contain a native class name or a script path.
// Otherwise the category was probably added via `@export_category` or `_get_property_list()`.
if (p.hint_string.is_empty()) {
category->label = p.name;
category->set_tooltip_text(p.name);
continue; // Do not add an icon, do not change the current class (`doc_name`).
}

Before it's parsed:
// Add editors at the start of a category.
for (Ref<EditorInspectorPlugin> &ped : valid_plugins) {
ped->parse_category(object, p.name);
_parse_added_editors(main_vbox, nullptr, ped);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants