Change color of treeitem separatedly

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By javi-desp

I would like to change the color of a treeitem by code, is this possible? Any idea?

:bust_in_silhouette: Reply From: jgodfrey

Yeah, you can do that. Here’s an example that 1) creates a new item, 2) sets its background color to RED, and 3) sets its foreground color to BLACK.

func _ready():
	var item = $Tree.create_item()
	item.set_text(0, "Item 1")
	item.set_custom_bg_color(0, Color.RED)
	item.set_custom_color(0, Color.BLACK)