diff options
Diffstat (limited to 'doc/classes/EditorPlugin.xml')
-rw-r--r-- | doc/classes/EditorPlugin.xml | 206 |
1 files changed, 172 insertions, 34 deletions
diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index 99fe9b4bb5..874fe4e3de 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -7,7 +7,7 @@ Plugins are used by the editor to extend functionality. The most common types of plugins are those which edit a given node or resource type, import plugins and export plugins. See also [EditorScript] to add functions to the editor. </description> <tutorials> - <link>https://docs.godotengine.org/en/latest/tutorials/plugins/editor/index.html</link> + <link title="Editor plugins tutorial index">https://docs.godotengine.org/en/latest/tutorials/plugins/editor/index.html</link> </tutorials> <methods> <method name="add_autoload_singleton"> @@ -76,6 +76,15 @@ During run-time, this will be a simple object with a script so this function does not need to be called then. </description> </method> + <method name="add_debugger_plugin"> + <return type="void"> + </return> + <argument index="0" name="script" type="Script"> + </argument> + <description> + Adds a [Script] as debugger plugin to the Debugger. The script must extend [EditorDebuggerPlugin]. + </description> + </method> <method name="add_export_plugin"> <return type="void"> </return> @@ -121,14 +130,10 @@ </return> <argument index="0" name="name" type="String"> </argument> - <argument index="1" name="handler" type="Object"> - </argument> - <argument index="2" name="callback" type="String"> - </argument> - <argument index="3" name="ud" type="Variant" default="null"> + <argument index="1" name="callable" type="Callable"> </argument> <description> - Adds a custom menu item to [b]Project > Tools[/b] as [code]name[/code] that calls [code]callback[/code] on an instance of [code]handler[/code] with a parameter [code]ud[/code] when user activates it. + Adds a custom menu item to [b]Project > Tools[/b] named [code]name[/code]. When clicked, the provided [code]callable[/code] will be called. </description> </method> <method name="add_tool_submenu_item"> @@ -139,7 +144,7 @@ <argument index="1" name="submenu" type="Object"> </argument> <description> - Adds a custom submenu under [b]Project > Tools >[/b] [code]name[/code]. [code]submenu[/code] should be an object of class [PopupMenu]. This submenu should be cleaned up using [code]remove_tool_menu_item(name)[/code]. + Adds a custom submenu under [b]Project > Tools >[/b] [code]name[/code]. [code]submenu[/code] should be an object of class [PopupMenu]. Use [code]remove_tool_menu_item(name)[/code] on plugin clean up to remove the menu. </description> </method> <method name="add_translation_parser_plugin"> @@ -201,6 +206,38 @@ <argument index="0" name="overlay" type="Control"> </argument> <description> + Called by the engine when the 2D editor's viewport is updated. Use the [code]overlay[/code] [Control] for drawing. You can update the viewport manually by calling [method update_overlays]. + [codeblocks] + [gdscript] + func forward_canvas_draw_over_viewport(overlay): + # Draw a circle at cursor position. + overlay.draw_circle(overlay.get_local_mouse_position(), 64) + + func forward_canvas_gui_input(event): + if event is InputEventMouseMotion: + # Redraw viewport when cursor is moved. + update_overlays() + return true + return false + [/gdscript] + [csharp] + public override void ForwardCanvasDrawOverViewport(Godot.Control overlay) + { + // Draw a circle at cursor position. + overlay.DrawCircle(overlay.GetLocalMousePosition(), 64, Colors.White); + } + + public override bool ForwardCanvasGuiInput(InputEvent @event) + { + if (@event is InputEventMouseMotion) + { + // Redraw viewport when cursor is moved. + UpdateOverlays(); + return true; + } + return false; + [/csharp] + [/codeblocks] </description> </method> <method name="forward_canvas_force_draw_over_viewport" qualifiers="virtual"> @@ -209,6 +246,8 @@ <argument index="0" name="overlay" type="Control"> </argument> <description> + This method is the same as [method forward_canvas_draw_over_viewport], except it draws on top of everything. Useful when you need an extra layer that shows over anything else. + You need to enable calling of this method by using [method set_force_draw_over_forwarding_enabled]. </description> </method> <method name="forward_canvas_gui_input" qualifiers="virtual"> @@ -218,21 +257,85 @@ </argument> <description> Called when there is a root node in the current edited scene, [method handles] is implemented and an [InputEvent] happens in the 2D viewport. Intercepts the [InputEvent], if [code]return true[/code] [EditorPlugin] consumes the [code]event[/code], otherwise forwards [code]event[/code] to other Editor classes. Example: - [codeblock] + [codeblocks] + [gdscript] # Prevents the InputEvent to reach other Editor classes func forward_canvas_gui_input(event): - var forward = true - return forward - [/codeblock] + return true + [/gdscript] + [csharp] + // Prevents the InputEvent to reach other Editor classes + public override bool ForwardCanvasGuiInput(InputEvent @event) + { + return true; + } + [/csharp] + [/codeblocks] Must [code]return false[/code] in order to forward the [InputEvent] to other Editor classes. Example: - [codeblock] - # Consumes InputEventMouseMotion and forwards other InputEvent types + [codeblocks] + [gdscript] + # Consumes InputEventMouseMotion and forwards other InputEvent types. func forward_canvas_gui_input(event): - var forward = false + return event is InputEventMouseMotion + [/gdscript] + [csharp] + // Consumes InputEventMouseMotion and forwards other InputEvent types. + public override bool ForwardCanvasGuiInput(InputEvent @event) + { + return @event is InputEventMouseMotion; + } + [/csharp] + [/codeblocks] + </description> + </method> + <method name="forward_spatial_draw_over_viewport" qualifiers="virtual"> + <return type="void"> + </return> + <argument index="0" name="overlay" type="Control"> + </argument> + <description> + Called by the engine when the 3D editor's viewport is updated. Use the [code]overlay[/code] [Control] for drawing. You can update the viewport manually by calling [method update_overlays]. + [codeblocks] + [gdscript] + func forward_spatial_draw_over_viewport(overlay): + # Draw a circle at cursor position. + overlay.draw_circle(overlay.get_local_mouse_position(), 64) + + func forward_spatial_gui_input(camera, event): if event is InputEventMouseMotion: - forward = true - return forward - [/codeblock] + # Redraw viewport when cursor is moved. + update_overlays() + return true + return false + [/gdscript] + [csharp] + public override void ForwardSpatialDrawOverViewport(Godot.Control overlay) + { + // Draw a circle at cursor position. + overlay.DrawCircle(overlay.GetLocalMousePosition(), 64, Colors.White); + } + + public override bool ForwardSpatialGuiInput(Godot.Camera3D camera, InputEvent @event) + { + if (@event is InputEventMouseMotion) + { + // Redraw viewport when cursor is moved. + UpdateOverlays(); + return true; + } + return false; + [/csharp] + [/codeblocks] + </description> + </method> + <method name="forward_spatial_force_draw_over_viewport" qualifiers="virtual"> + <return type="void"> + </return> + <argument index="0" name="overlay" type="Control"> + </argument> + <description> + This method is the same as [method forward_spatial_draw_over_viewport], except it draws on top of everything. Useful when you need an extra layer that shows over anything else. + You need to enable calling of this method by using [method set_force_draw_over_forwarding_enabled]. </description> </method> <method name="forward_spatial_gui_input" qualifiers="virtual"> @@ -244,21 +347,35 @@ </argument> <description> Called when there is a root node in the current edited scene, [method handles] is implemented and an [InputEvent] happens in the 3D viewport. Intercepts the [InputEvent], if [code]return true[/code] [EditorPlugin] consumes the [code]event[/code], otherwise forwards [code]event[/code] to other Editor classes. Example: - [codeblock] - # Prevents the InputEvent to reach other Editor classes + [codeblocks] + [gdscript] + # Prevents the InputEvent to reach other Editor classes. func forward_spatial_gui_input(camera, event): - var forward = true - return forward - [/codeblock] + return true + [/gdscript] + [csharp] + // Prevents the InputEvent to reach other Editor classes. + public override bool ForwardSpatialGuiInput(Camera3D camera, InputEvent @event) + { + return true; + } + [/csharp] + [/codeblocks] Must [code]return false[/code] in order to forward the [InputEvent] to other Editor classes. Example: - [codeblock] - # Consumes InputEventMouseMotion and forwards other InputEvent types + [codeblocks] + [gdscript] + # Consumes InputEventMouseMotion and forwards other InputEvent types. func forward_spatial_gui_input(camera, event): - var forward = false - if event is InputEventMouseMotion: - forward = true - return forward - [/codeblock] + return event is InputEventMouseMotion + [/gdscript] + [csharp] + // Consumes InputEventMouseMotion and forwards other InputEvent types. + public override bool ForwardSpatialGuiInput(Camera3D camera, InputEvent @event) + { + return @event is InputEventMouseMotion; + } + [/csharp] + [/codeblocks] </description> </method> <method name="get_breakpoints" qualifiers="virtual"> @@ -282,13 +399,24 @@ Override this method in your plugin to return a [Texture2D] in order to give it an icon. For main screen plugins, this appears at the top of the screen, to the right of the "2D", "3D", "Script", and "AssetLib" buttons. Ideally, the plugin icon should be white with a transparent background and 16x16 pixels in size. - [codeblock] + [codeblocks] + [gdscript] func get_plugin_icon(): # You can use a custom icon: return preload("res://addons/my_plugin/my_plugin_icon.svg") # Or use a built-in icon: return get_editor_interface().get_base_control().get_icon("Node", "EditorIcons") - [/codeblock] + [/gdscript] + [csharp] + public override Texture2D GetPluginIcon() + { + // You can use a custom icon: + return ResourceLoader.Load<Texture2D>("res://addons/my_plugin/my_plugin_icon.svg"); + // Or use a built-in icon: + return GetEditorInterface().GetBaseControl().GetIcon("Node", "EditorIcons"); + } + [/csharp] + [/codeblocks] </description> </method> <method name="get_plugin_name" qualifiers="virtual"> @@ -370,7 +498,7 @@ Remember that you have to manage the visibility of all your editor controls manually. </description> </method> - <method name="queue_save_layout" qualifiers="const"> + <method name="queue_save_layout"> <return type="void"> </return> <description> @@ -424,6 +552,15 @@ Removes a custom type added by [method add_custom_type]. </description> </method> + <method name="remove_debugger_plugin"> + <return type="void"> + </return> + <argument index="0" name="script" type="Script"> + </argument> + <description> + Removes the debugger plugin with given script fromm the Debugger. + </description> + </method> <method name="remove_export_plugin"> <return type="void"> </return> @@ -493,6 +630,7 @@ <return type="void"> </return> <description> + Enables calling of [method forward_canvas_force_draw_over_viewport] for the 2D editor and [method forward_spatial_force_draw_over_viewport] for the 3D editor when their viewports are updated. You need to call this method only once and it will work permanently for this plugin. </description> </method> <method name="set_input_event_forwarding_always_enabled"> @@ -524,7 +662,7 @@ <return type="int"> </return> <description> - Updates the overlays of the editor (2D/3D) viewport. + Updates the overlays of the 2D and 3D editor viewport. Causes methods [method forward_canvas_draw_over_viewport], [method forward_canvas_force_draw_over_viewport], [method forward_spatial_draw_over_viewport] and [method forward_spatial_force_draw_over_viewport] to be called. </description> </method> </methods> |