diff options
author | kobewi <kobewi4e@gmail.com> | 2022-12-19 11:51:37 +0100 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2022-12-19 11:51:37 +0100 |
commit | 32b0770a7382325305bdfb008665b7e150778124 (patch) | |
tree | d4bbf250b0b610942afd11f4b5b57fd7b4ce8b5b /scene | |
parent | e780dc332a0a3f642a6daf8548cb211d79a2cc45 (diff) | |
download | redot-engine-32b0770a7382325305bdfb008665b7e150778124.tar.gz |
Add a method to get global modulate
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/canvas_item.cpp | 10 | ||||
-rw-r--r-- | scene/main/canvas_item.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index 2563fa5914..76d5494ce3 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -388,6 +388,16 @@ Color CanvasItem::get_modulate() const { return modulate; } +Color CanvasItem::get_modulate_in_tree() const { + Color final_modulate = modulate; + CanvasItem *parent_item = get_parent_item(); + while (parent_item) { + final_modulate *= parent_item->get_modulate(); + parent_item = parent_item->get_parent_item(); + } + return final_modulate; +} + void CanvasItem::set_as_top_level(bool p_top_level) { if (top_level == p_top_level) { return; diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h index 4ace982825..a60a2bb5a1 100644 --- a/scene/main/canvas_item.h +++ b/scene/main/canvas_item.h @@ -224,6 +224,7 @@ public: void set_modulate(const Color &p_modulate); Color get_modulate() const; + Color get_modulate_in_tree() const; void set_self_modulate(const Color &p_self_modulate); Color get_self_modulate() const; |