summaryrefslogtreecommitdiff
path: root/doc/classes/EditorPlugin.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/EditorPlugin.xml')
-rw-r--r--doc/classes/EditorPlugin.xml176
1 files changed, 150 insertions, 26 deletions
diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml
index 6a64a7aa55..ca011abb36 100644
--- a/doc/classes/EditorPlugin.xml
+++ b/doc/classes/EditorPlugin.xml
@@ -210,6 +210,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">
@@ -218,6 +250,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">
@@ -227,21 +261,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">
@@ -253,21 +351,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">
@@ -291,13 +403,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&lt;Texture2D&gt;("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">
@@ -379,7 +502,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>
@@ -511,6 +634,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">
@@ -542,7 +666,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>