Skip to content

Commit e86c012

Browse files
Merge pull request #12159 from mattmassicotte/patch-1
Address issues with creating a dock editor
1 parent d3e3b86 commit e86c012

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

tutorials/plugins/editor/making_plugins.rst

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,44 @@ add the following content to it:
272272
version="1.0"
273273
script="CustomDock.cs"
274274

275-
Then create the script ``custom_dock.gd`` in the same folder. Fill it with the
276-
:ref:`template we've seen before <doc_making_plugins_template_code>` to get a
277-
good start.
275+
Then create the script ``custom_dock.gd`` in the same folder. The following code
276+
will get you started.
277+
278+
.. tabs::
279+
.. code-tab:: gdscript GDScript
280+
281+
@tool
282+
extends EditorDock
283+
284+
285+
func _enter_tree():
286+
# Initialization of the dock goes here.
287+
pass
288+
289+
290+
func _exit_tree():
291+
# Clean-up of the dock goes here.
292+
pass
293+
294+
.. code-tab:: csharp
295+
296+
#if TOOLS
297+
using Godot;
298+
299+
[Tool]
300+
public partial class CustomNode : EditorDock
301+
{
302+
public override void _EnterTree()
303+
{
304+
// Initialization of the dock goes here.
305+
}
306+
307+
public override void _ExitTree()
308+
{
309+
// Clean-up of the dock goes here.
310+
}
311+
}
312+
#endif
278313

279314
Since we're trying to add a new custom dock, we need to create the contents of
280315
the dock. This is nothing more than a standard Godot scene: just create
@@ -319,7 +354,7 @@ The script could look like this:
319354
dock.title = "My Dock"
320355

321356
# Note that LEFT_UL means the left of the editor, upper-left dock.
322-
dock.default_slot = DOCK_SLOT_LEFT_UL
357+
dock.default_slot = EditorDock.DOCK_SLOT_LEFT_UL
323358

324359
# Allow the dock to be on the left or right of the editor, and to be made floating.
325360
dock.available_layouts = EditorDock.DOCK_LAYOUT_VERTICAL | EditorDock.DOCK_LAYOUT_FLOATING

0 commit comments

Comments
 (0)