public static void DFSGetChildren(this Transform transform, TransformAction action) { var childCount = transform.childCount; for (var index = 0; index < childCount; index++) { var child = transform.GetChild(index); if (action.Invoke(child)) { child.DFSGetChildren(action); } } }
public Tuple <string, string>[] CollectSub(string name, TransformAction action = null) { List <Tuple <string, string> > l = new List <Tuple <string, string> >(); foreach (var data in nestedData) { if (data.Name.Equals(name)) { l.Add(new Tuple <string, string>(data.InnerText, action?.Invoke(data) ?? "")); } } return(l.ToArray()); }
public static void BFSGetChildren(this Transform transform, TransformAction action) { var childCount = transform.childCount; var transformList = new List <Transform>(); for (var index = 0; index < childCount; index++) { var child = transform.GetChild(index); if (action.Invoke(child)) { transformList.Add(child); } } for (var index = 0; index < transformList.Count; index++) { var child = transformList[index]; child.BFSGetChildren(action); } }