Is it possible to check if the child of fore_layers is canvas modulate or colorrectangle before setting it? This is what I currently have
Im not sure exactly how to use the return function but whenever I set "layers" to type array on the function I get an error, same with trying to return as type Object or Node using ->, it says get_child is not a built in function of array despite me being able to run it on its own
#Help with the return function and setting a color only when a child node is of a certain type
1 messages · Page 1 of 1 (latest)
If you want to use a custom function:
if fore_layers[i].get_child_count() > 1 and is_correct_child_type(fore_layers[i]):
func is_correct_child_type(layer):
if layer is CanvasModulate or layer is ColorRect:
return true
return false
I need the child of fore_layers[i] not forelayers[i] itself, forelayers[i] is an array of canvaslayers
Oh easy fix
if fore_layers[i].get_child_count() > 1 and is_correct_child_type(fore_layers[i]):
func is_correct_child_type(layers):
for layer in layers:
if layer is CanvasModulate or layer is ColorRect:
return true
return false
thank you
any idea whats up with this error btw?
wait hold on this still isn't obtaining the children is it? its taking one of the canvas layers in the array
if fore_layers[i].get_child_count() > 1 and get_child_type(fore_layers[i]):
func get_child_type(layers):
for child in layers:
if child is CanvasModulate or child is ColorRect:
return child
@vale summit
fore_layers[i] is a canvaslayer right?
since i see u setting the follow_viewport_scale property
and u wanna check the childrens of canvaslayer?
yes
Okay give me a minute
if fore_layers[i].get_child_count() > 1:
for child in fore_layers[i].get_children():
if child is CanvasModulate or child is ColorRect:
child.color = modulate_setter
@vale summit
Is this what ur expecting?
I believe so, thank you.