public static T FindFirstNodeOf <T>(this Godot.Node node) where T : Godot.Node { foreach (Godot.Node child in node.GetChildren()) { if (child is T) { return((T)child); } } return(null); }
public static Godot.Node[] GetChildrenRecursive(this Godot.Node parent) { List <Godot.Node> result = new List <Godot.Node>(); foreach (Godot.Node node in parent.GetChildren()) { result.Add(node); if (node.GetChildCount() > 0) { foreach (Godot.Node child in GetChildrenRecursive(node)) { result.Add(child); } } } return(result.ToArray()); }
public static Array <T> FindAllNodesOf <T>(this Godot.Node node) where T : Godot.Node { var matching = new Array <T>(); foreach (Godot.Node child in node.GetChildren()) { if (child is T) { matching.Add((T)child); } Array <T> kids = child.FindAllNodesOf <T>(); foreach (T kid in kids) { matching.Add(kid); } } return(matching); }