Skip to content

Commit 7648846

Browse files
mateuseapraulsntos
andcommitted
Add missing C# code in making plugins tutorial
Co-authored-by: Raul Santos <[email protected]>
1 parent 010d41e commit 7648846

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tutorials/plugins/editor/making_plugins.rst

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ an autoload.
432432

433433
Use the following code to register a singleton from an editor plugin:
434434

435-
::
435+
.. tabs::
436+
.. code-tab:: gdscript GDScript
436437

437438
@tool
438439
extends EditorPlugin
@@ -448,3 +449,27 @@ Use the following code to register a singleton from an editor plugin:
448449

449450
func _exit_tree():
450451
remove_autoload_singleton(AUTOLOAD_NAME)
452+
453+
.. code-tab:: csharp
454+
455+
#if TOOLS
456+
using Godot;
457+
458+
[Tool]
459+
public partial class MyEditorPlugin : EditorPlugin
460+
{
461+
// Replace this value with a PascalCase autoload name.
462+
private const string AutoloadName = "SomeAutoload";
463+
464+
public override void _EnterTree()
465+
{
466+
// The autoload can be a scene or script file.
467+
AddAutoloadSingleton(AutoloadName, "res://addons/MyAddon/SomeAutoload.tscn");
468+
}
469+
470+
public override void _ExitTree()
471+
{
472+
RemoveAutoloadSingleton(AutoloadName);
473+
}
474+
}
475+
#endif

0 commit comments

Comments
 (0)