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

Tool scripts export categories and their properties to the inspector twice #63454

Closed
MagdielM opened this issue Jul 25, 2022 · 4 comments · Fixed by #58443
Closed

Tool scripts export categories and their properties to the inspector twice #63454

MagdielM opened this issue Jul 25, 2022 · 4 comments · Fixed by #58443

Comments

@MagdielM
Copy link

Godot version

4.0.alpha12.official [2c11e6d]

System information

Windows 10

Issue description

Tool scripts that export properties under a category using @export_category will have this category and properties shown twice in the inspector.
image

image

Steps to reproduce

From a new project:

  1. Create a tool script and attach it to whichever object it extends.
  2. Use the @export_category annotation to add a category.
  3. Export one or more properties.
  4. Inspect the object with the tool script attached.
  5. Note how the category and properties are displayed twice.

From the reproduction project:

  1. Open new_resource.tres.
  2. Note how the "Category" category and its associated properties are displayed twice.

Minimal reproduction project

Duplicate Property Repro.zip

@Calinou
Copy link
Member

Calinou commented Jul 25, 2022

cc @YuriSizov

@YuriSizov YuriSizov self-assigned this Jul 26, 2022
@YuriSizov
Copy link
Contributor

This is related to the logic introduced by #32428. The approach from that PR is based around taking a list of properties that doesn't have script-class grouping and rebuilding that part from scratch, and then removing the original properties.

The problem is, it breaks in the case of annotations because it is made to stop at the first category. So if you add a category in your property list, it thinks it's time to stop there. Accidentally, this doesn't happen if you use the old school way with _get_property_list(), but that seems to actually be an issue with the original implementation.

So this works:

@tool
extends Node

func _get_property_list() -> Array:
	var properties := []
	
	properties.push_back({
		"name": "Extra Category",
		"type": TYPE_NIL,
		"usage": PROPERTY_USAGE_CATEGORY,
	})
	properties.push_back({
		"name": "some_variable",
		"type": TYPE_INT,
		"USAGE": PROPERTY_USAGE_DEFAULT,
	})
	
	return properties

And this breaks:

@tool
extends Node

@export_category("Extra Category")
@export var some_variable : int

While trying to figure out the logic behind #32428 and if it could be improved, I realized that in the current master _get_property_list just doesn't work, unless you have categories. And thus it all comes full circle. Luckily, there is a PR that fixes the _get_property_list issues by removing duplicated properties instead of removing everything in the list between two predefined marks. This one: #58443

I've tested #58443 and it fixes this issue as well. So let's wait for it to either be merged, or improved.

@mbrlabs
Copy link
Contributor

mbrlabs commented Jul 29, 2022

This issue is still present for for non-tool scripts in alpha 13 and master (9869182)

extends Node
@export var my_string: String

my_string shows up twice in the inspector.

@akien-mga
Copy link
Member

Closing again as we're consolidating the new issues in #63668.

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

Successfully merging a pull request may close this issue.

5 participants