godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.77k stars 3.06k forks source link

Plugins docs on Dotnet C# EditorInterface to get singleton is wrong and misleading #9626

Open DamienFremont opened 1 month ago

DamienFremont commented 1 month ago

Your Godot version: 4.3, 4.2

Issue description:

Compile error using C# on godot-demo-projects:plugins:main_screen https://github.com/DamienFremont/godot-demo-projects/tree/master/plugins/addons/main_screen

Plugin script should be using EditorInterface.singleton. instead of EditorInterface.

URL to the documentation page: https://docs.godotengine.org/en/latest/tutorials/plugins/editor/making_main_screen_plugins.html

Fix + PR: https://github.com/godotengine/godot-docs/pull/9627

Test project https://github.com/DamienFremont/godot-demo-projects/tree/fix-docs-dotnet-editorinterface-singleton-usage/plugins

Screenshots:

20240720_170834-Zoomit Zoom Window

20240720_170647-Window

20240720_170700-Window

AThousandShips commented 1 month ago

This is not wrong, see https://github.com/godotengine/godot-docs/pull/9399#issuecomment-2119334224, though it's one of two different ways of doing this, however neither is more or less correct

GeneralProtectionFault commented 1 month ago

I ran into this and came to see if there was an issue, and there was =D. @AThousandShips What is it that's not wrong, though? This isn't about which way to implement, it's about the documentation, right?

The C# code example on the referenced documentation is wrong--outright won't build. I'm assuming the proposal is simply replace this: public override Texture2D _GetPluginIcon() { return EditorInterface.GetEditorTheme().GetIcon("Node", "EditorIcons"); }

...with this: public override Texture2D _GetPluginIcon() { return EditorInterface.Singleton.GetEditorTheme().GetIcon("Node", "EditorIcons"); }

It's in two spots on the docs page.