From 1518d813beaa918abe9b60eee8b44e75ba150efb Mon Sep 17 00:00:00 2001 From: Micky Date: Tue, 27 Sep 2022 18:53:14 +0200 Subject: Support nesting AtlasTextures inside other AtlasTextures Connects AtlasTexture to its `atlas`'s "changed" signal, allowing it to detect property changes to `atlas` and update accordingly, when the project is running and in the editor, as well. --- scene/resources/texture.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'scene') diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 15678c9281..5a03929f98 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -1489,7 +1489,15 @@ void AtlasTexture::set_atlas(const Ref &p_atlas) { if (atlas == p_atlas) { return; } + // Support recursive AtlasTextures. + if (Ref(atlas).is_valid()) { + atlas->disconnect(CoreStringNames::get_singleton()->changed, callable_mp((Resource *)this, &AtlasTexture::emit_changed)); + } atlas = p_atlas; + if (Ref(atlas).is_valid()) { + atlas->connect(CoreStringNames::get_singleton()->changed, callable_mp((Resource *)this, &AtlasTexture::emit_changed)); + } + emit_changed(); } -- cgit v1.2.3