Register methods for drawing 3D editor overlays
(cherry picked from commit cbfbb4538b
)
This commit is contained in:
parent
da2ac44d77
commit
dc05beca80
2 changed files with 35 additions and 2 deletions
|
@ -241,6 +241,37 @@
|
|||
[/codeblock]
|
||||
</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].
|
||||
[codeblock]
|
||||
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:
|
||||
# Redraw viewport when cursor is moved.
|
||||
update_overlays()
|
||||
return true
|
||||
return false
|
||||
[/codeblock]
|
||||
</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">
|
||||
<return type="bool">
|
||||
</return>
|
||||
|
@ -490,7 +521,7 @@
|
|||
<return type="void">
|
||||
</return>
|
||||
<description>
|
||||
Enables calling of [method forward_canvas_force_draw_over_viewport] when the 2D editor's viewport is updated. You need to call this method only once and it will work permanently for this plugin.
|
||||
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">
|
||||
|
@ -522,7 +553,7 @@
|
|||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Updates the overlays of the 2D and 3D editor viewport. Causes [method forward_canvas_draw_over_viewport] and [method forward_canvas_force_draw_over_viewport] to be called.
|
||||
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>
|
||||
|
|
|
@ -904,6 +904,8 @@ void EditorPlugin::_bind_methods() {
|
|||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name"));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "get_plugin_icon"));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "has_main_screen"));
|
||||
|
|
Loading…
Reference in a new issue