From ff60ad4207936f4ea83f23550186356df37c3504 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 23 Oct 2019 16:00:09 +0200 Subject: [PATCH] Added a "texture_added" signal, and the 2 signals are also available as vmethods now. --- texture_merger.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/texture_merger.cpp b/texture_merger.cpp index 77e33ae..ff815d6 100644 --- a/texture_merger.cpp +++ b/texture_merger.cpp @@ -88,7 +88,14 @@ Ref TextureMerger::add_texture(Ref texture) { _textures.push_back(texture); - return _packer->add_texture(texture); + Ref tex = _packer->add_texture(texture); + + if (has_method("_texture_added")) + call("_texture_added", tex); + + emit_signal("texture_added", tex); + + return tex; } Ref TextureMerger::get_original_texture(int index) { @@ -137,6 +144,9 @@ int TextureMerger::get_generated_texture_count() { void TextureMerger::merge() { _packer->merge(); + if (has_method("_texture_merged")) + call("_texture_merged"); + emit_signal("texture_merged"); } @@ -153,6 +163,10 @@ TextureMerger::~TextureMerger() { void TextureMerger::_bind_methods() { ADD_SIGNAL(MethodInfo("texture_merged")); + ADD_SIGNAL(MethodInfo("texture_added")); + + BIND_VMETHOD(MethodInfo("_texture_merged")); + BIND_VMETHOD(MethodInfo("_texture_added", PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture"))); ClassDB::bind_method(D_METHOD("get_texture_flags"), &TextureMerger::get_texture_flags); ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &TextureMerger::set_texture_flags);