|
@@ -4080,9 +4080,26 @@ Viewport::~Viewport() {
|
|
|
/////////////////////////////////
|
|
|
|
|
|
void SubViewport::set_size(const Size2i &p_size) {
|
|
|
- _set_size(p_size, _get_size_2d_override(), Rect2i(), _stretch_transform(), true);
|
|
|
+ _internal_set_size(p_size);
|
|
|
+}
|
|
|
|
|
|
+void SubViewport::set_size_force(const Size2i &p_size) {
|
|
|
+ // Use only for setting the size from the parent SubViewportContainer with enabled stretch mode.
|
|
|
+ // Don't expose function to scripting.
|
|
|
+ _internal_set_size(p_size, true);
|
|
|
+}
|
|
|
+
|
|
|
+void SubViewport::_internal_set_size(const Size2i &p_size, bool p_force) {
|
|
|
SubViewportContainer *c = Object::cast_to<SubViewportContainer>(get_parent());
|
|
|
+ if (!p_force && c && c->is_stretch_enabled()) {
|
|
|
+#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
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ _set_size(p_size, _get_size_2d_override(), Rect2i(), _stretch_transform(), true);
|
|
|
+
|
|
|
if (c) {
|
|
|
c->update_minimum_size();
|
|
|
}
|