diff options
Diffstat (limited to 'scene/2d/canvas_modulate.cpp')
-rw-r--r-- | scene/2d/canvas_modulate.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp index 77203a7110..cc0db2da77 100644 --- a/scene/2d/canvas_modulate.cpp +++ b/scene/2d/canvas_modulate.cpp @@ -5,19 +5,30 @@ void CanvasModulate::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_CANVAS) { - if (is_visible()) + if (is_visible()) { VS::get_singleton()->canvas_set_modulate(get_canvas(),color); + add_to_group("_canvas_modulate_"+itos(get_canvas().get_id())); + } + + + } else if (p_what==NOTIFICATION_EXIT_CANVAS) { - if (is_visible()) + if (is_visible()) { VS::get_singleton()->canvas_set_modulate(get_canvas(),Color(1,1,1,1)); + remove_from_group("_canvas_modulate_"+itos(get_canvas().get_id())); + } } else if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { if (is_visible()) { VS::get_singleton()->canvas_set_modulate(get_canvas(),color); + add_to_group("_canvas_modulate_"+itos(get_canvas().get_id())); } else { VS::get_singleton()->canvas_set_modulate(get_canvas(),Color(1,1,1,1)); + remove_from_group("_canvas_modulate_"+itos(get_canvas().get_id())); } + + update_configuration_warning(); } } @@ -42,6 +53,20 @@ Color CanvasModulate::get_color() const { return color; } +String CanvasModulate::get_configuration_warning() const { + + if (!is_visible() || !is_inside_tree()) + return String(); + + List<Node*> nodes; + get_tree()->get_nodes_in_group("_canvas_modulate_"+itos(get_canvas().get_id()),&nodes); + + if (nodes.size()>1) { + return TTR("Only one visible CanvasModulate is allowed per scene (or set of instanced scenes). The first one created will work, while the rest will be ignored."); + } + + return String(); +} CanvasModulate::CanvasModulate() { |