From 4666084d8463f3b413f14fc3a3670231e627ecc5 Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Thu, 2 Feb 2023 01:04:05 +0100 Subject: [PATCH] Lift editing SubViewport size restriction in editor Editing size of a SubViewport that is a child of a SubViewportContainer which has stretch enabled is currently forbidden. This restriction doesn't make sense while in the editor. This PR lifts this restriction. --- scene/main/viewport.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index c31155bd5c7e..c701e6152ed8 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -4136,7 +4136,11 @@ void SubViewport::set_size_force(const Size2i &p_size) { void SubViewport::_internal_set_size(const Size2i &p_size, bool p_force) { SubViewportContainer *c = Object::cast_to(get_parent()); - if (!p_force && c && c->is_stretch_enabled()) { + bool forbidden_change = !p_force && c && c->is_stretch_enabled(); +#ifdef TOOLS_ENABLED + forbidden_change = forbidden_change && !(Engine::get_singleton()->is_editor_hint() && is_inside_tree() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this)); +#endif // TOOLS_ENABLED + if (forbidden_change) { #ifdef DEBUG_ENABLED WARN_PRINT("Can't change the size of a `SubViewport` with a `SubViewportContainer` parent that has `stretch` enabled. Set `SubViewportContainer.stretch` to `false` to allow changing the size manually."); #endif // DEBUG_ENABLED