Skip to content

Commit f967e9e

Browse files
authored
Fix C# main screen plugin example and document C# EditorInterface singleton (#9399)
* 🐞 fix(plugins): fix syntax errors Correct the syntax errors in the plugin development section, specifically by modifying 'EditorInterface' to 'EditorInterface.Singleton' in the C# portion. It is imperative to utilize the singleton pattern here to ensure the plugin successfully compiles. * 🐞 fix(different): ADD exceptions Provide explanations for Singleton exceptions of `EditorInterface`
1 parent fdf7e1a commit f967e9e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

tutorials/plugins/editor/making_main_screen_plugins.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Add five extra methods such that the script looks like this:
9292

9393
public override Texture2D _GetPluginIcon()
9494
{
95-
return EditorInterface.GetEditorTheme().GetIcon("Node", "EditorIcons");
95+
return EditorInterface.Singleton.GetEditorTheme().GetIcon("Node", "EditorIcons");
9696
}
9797
}
9898
#endif
@@ -210,7 +210,7 @@ Here is the full plugin script:
210210
{
211211
MainPanelInstance = (Control)MainPanel.Instantiate();
212212
// Add the main panel to the editor's main viewport.
213-
EditorInterface.GetEditorMainScreen().AddChild(MainPanelInstance);
213+
EditorInterface.Singleton.GetEditorMainScreen().AddChild(MainPanelInstance);
214214
// Hide the main panel. Very much required.
215215
_MakeVisible(false);
216216
}
@@ -244,7 +244,7 @@ Here is the full plugin script:
244244
public override Texture2D _GetPluginIcon()
245245
{
246246
// Must return some kind of Texture for the icon.
247-
return EditorInterface.GetEditorTheme().GetIcon("Node", "EditorIcons");
247+
return EditorInterface.Singleton.GetEditorTheme().GetIcon("Node", "EditorIcons");
248248
}
249249
}
250250
#endif

tutorials/scripting/c_sharp/c_sharp_differences.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,17 @@ Example:
363363
364364
Input.Singleton.JoyConnectionChanged += Input_JoyConnectionChanged;
365365
366+
If you are developing main screen plugins using C#, it is essential to note the
367+
distinctions between ``GDScript`` and ``C#`` during setup. Unlike in ``GDScript``,
368+
this portion is not a static class in ``C#``. Consequently, you must employ the singleton
369+
pattern to obtain an instance of the ``EditorInterface``:
370+
371+
==================== ==============================================================
372+
GDScript C#
373+
==================== ==============================================================
374+
``EditorInterface`` ``EditorInterface.Singleton``
375+
==================== ==============================================================
376+
366377
String
367378
------
368379

0 commit comments

Comments
 (0)