1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-26 15:46:23 +00:00

Add a method to get global modulate

This commit is contained in:
kobewi
2022-12-19 11:51:37 +01:00
parent e780dc332a
commit 32b0770a73
3 changed files with 12 additions and 1 deletions

View File

@@ -922,7 +922,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over
// Get the tile modulation. // Get the tile modulation.
Color modulate = tile_data->get_modulate(); Color modulate = tile_data->get_modulate();
Color self_modulate = tile_map->get_self_modulate(); Color self_modulate = tile_map->get_modulate_in_tree() * tile_map->get_self_modulate();
modulate *= self_modulate; modulate *= self_modulate;
// Draw the tile. // Draw the tile.

View File

@@ -388,6 +388,16 @@ Color CanvasItem::get_modulate() const {
return modulate; 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) { void CanvasItem::set_as_top_level(bool p_top_level) {
if (top_level == p_top_level) { if (top_level == p_top_level) {
return; return;

View File

@@ -224,6 +224,7 @@ public:
void set_modulate(const Color &p_modulate); void set_modulate(const Color &p_modulate);
Color get_modulate() const; Color get_modulate() const;
Color get_modulate_in_tree() const;
void set_self_modulate(const Color &p_self_modulate); void set_self_modulate(const Color &p_self_modulate);
Color get_self_modulate() const; Color get_self_modulate() const;