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

Debugger hierarchy is not the same between Standard Godot and Mono Godot #89326

Closed
OmnesPotens opened this issue Mar 9, 2024 · 6 comments
Closed
Labels

Comments

@OmnesPotens
Copy link

OmnesPotens commented Mar 9, 2024

Tested versions

  • Discovered on v4.2.1.stable.official [b09f793] Standard and v4.2.1.stable.mono.official [b09f793] Mono
  • Reproducible on v4.1.stable.official [9704596] Standard and v4.1.stable.mono.official [9704596] Mono, but in a different location
  • Unknown if this behavior is happening in other versions

System information

Windows 10 - Godot Engine v4.1.stable.mono.official.970459615 - https://godotengine.org Vulkan API 1.3.277 - Forward+ - NVIDIA GeForce GTX 1080 Ti

Issue description

Effectively, running the same exact GDScript code in Standard Godot results in the expected hierarchy, while running in Mono Godot results in an extra button (and likely other) minor differences in the Editor/Debugger structure. Have only noticed this discrepancy on the EditorRunBar so far, but there are likely other differences as well.

Expected Standard and Mono Godot to have the same Editor hierarchy of objects/elements.

Creating a new, empty project results in the same differences.

Standard Godot EditorRunBar hierarchy:
image

Mono Godot EditorRunBar hierarchy:
image

  • Notice the extra Button below HBoxContainer@4075

Standard Godot EditorTitleBar hierarchy (4.1):
image

Mono Godot EditorTitleBar hierarchy (4.1):
image

  • Notice the extra Button below HBoxContainer@4829

Steps to reproduce

  1. Create new empty project
  2. Install https://github.com/Zylann/godot_editor_debugger_plugin
  3. Open the project in Standard Godot
  4. Hover mouse over EditorTitleBar and press F12 key
  5. Make sure EditorTitleBar hierarchy is fully expanded
  6. Open the project in Mono Godot
  7. Repeat Steps 4 & 5
  8. Compare the hierarchies produced by Standard and Mono Godot
  9. Observe discrepancies in the produced hierarchies with Mono including at least 1 additional Button

Minimal reproduction project (MRP)

editor-hierarchy-compare.zip

@akien-mga
Copy link
Member

That's not a bug. The Mono version of Godot adds a feature (C# support), which comes with some editor UI.
The button you found is the "Build" button to compile the C# solution.

The hierarchy of the editor is influenced by any plugins, even the editor debugger plugin you're using impacts it by adding a new dock.

@OmnesPotens
Copy link
Author

OmnesPotens commented Mar 9, 2024

That's not a bug. The Mono version of Godot adds a feature (C# support), which comes with some editor UI. The button you found is the "Build" button to compile the C# solution.

The hierarchy of the editor is influenced by any plugins, even the editor debugger plugin you're using impacts it by adding a new dock.

I see ☹️. Is there a more robust way to get references to editor buttons instead of using indexes based on children of some parent?

Example with indices:

run_bar = Utils.find_child(editor_title_bar, "EditorRunBar")
var run_bar_buttons = run_bar.find_children("", "Button", true, false)
run_bar_play_button = run_bar_buttons[1]

@akien-mga
Copy link
Member

Not that I know of. Currently things which are not explicitly exposed in the API shouldn't be considered part of the API, and any future refactoring of internal editor code may break your plugin's expectations.

We're aware that we don't expose enough things currently to allow plugins to mod the editor reliably, that's something that requires discussion to see what and how to expose more things and make them officially part of the API (which means less flexibility for engine developers to refactor code as there's more risk of breaking "soft" APIs, see e.g. #89302).

There might be clever ways to figure out which button is which though, which would still not be supported / considered part of the API, but might be less prone to random changes. E.g. checking what's their icon, or the tooltip text... yeah this is bad :P

CC @KoBeWi

@KoBeWi
Copy link
Member

KoBeWi commented Mar 9, 2024

checking what's their icon, or the tooltip text

Basically this. In case of EditorRunBar, you can either find them by icon

var target_button_icon := EditorInterface.get_editor_theme().get_icon(&"MainPlay")
for button: Button in run_bar_buttons:
	if button.icon == target_button_icon:
		return button

or by shortcut:

for button: BaseButton in run_bar_buttons:
	if not button.shortcut:
		continue
	for event in button.shortcut.events:
		if event is InputEventKey and event.keycode == KEY_F5:
			return button

or by tooltip text (although that's translated, so it's problematic). But as I said in #89225 (comment), if you want a robust and reliable way, the only possibility is opening a proposal for exposing it to the official API.

What do you need the exact button for?

(btw I recently started making a script called "Editor Hacks" that would provide methods for fetching or calling unexposed stuff, but it's not public yet; I'm collecting ideas for now).

@OmnesPotens
Copy link
Author

Hm I understand. Alternatively maybe there is some way to determine which version/architecture of Godot is being used?

@akien-mga
Copy link
Member

Sure, Engine.get_version_info() and Engine.get_architecture_name().

I'll close this issue as it's not an actionable bug report, but further discussion can happen in a proposal/discussion on godot-proposals or in a thread on the forum. We're definitely interested in hearing more about use cases from plugin developers to decide how to expand the existing API.

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

No branches or pull requests

3 participants