Browse Source

Merge pull request #67370 from KoBeWi/queueueuedraw

Redraw 2D viewport when scene changes
Rémi Verschelde 2 years ago
parent
commit
bd4fddd89f

+ 9 - 0
editor/plugins/canvas_item_editor_plugin.cpp

@@ -5455,6 +5455,15 @@ void CanvasItemEditorPlugin::set_state(const Dictionary &p_state) {
 	canvas_item_editor->set_state(p_state);
 }
 
+void CanvasItemEditorPlugin::_notification(int p_what) {
+	switch (p_what) {
+		case NOTIFICATION_ENTER_TREE: {
+			connect("scene_changed", callable_mp((CanvasItem *)canvas_item_editor->get_viewport_control(), &CanvasItem::queue_redraw).unbind(1));
+			connect("scene_closed", callable_mp((CanvasItem *)canvas_item_editor->get_viewport_control(), &CanvasItem::queue_redraw).unbind(1));
+		} break;
+	}
+}
+
 CanvasItemEditorPlugin::CanvasItemEditorPlugin() {
 	canvas_item_editor = memnew(CanvasItemEditor);
 	canvas_item_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);

+ 3 - 0
editor/plugins/canvas_item_editor_plugin.h

@@ -563,6 +563,9 @@ class CanvasItemEditorPlugin : public EditorPlugin {
 
 	CanvasItemEditor *canvas_item_editor = nullptr;
 
+protected:
+	void _notification(int p_what);
+
 public:
 	virtual String get_name() const override { return "2D"; }
 	bool has_main_screen() const override { return true; }