novial
novial
CC#
Created by novial on 1/14/2024 in #help
better way to do this?
No description
34 replies
CC#
Created by novial on 8/19/2023 in #help
❔ code simplification
any way to simplify this?
private Transform[] allChildrenHelper(List<Transform> children)
{
foreach (Transform child in Children)
{
children.Add(child);
children = (List<Transform>)children.Concat(allChildrenHelper(children));
}
return children.ToArray();
}
/// <summary>
/// Gets all children of this game object.
/// </summary>
public Transform[] AllChildren => allChildrenHelper(new List<Transform>());
private Transform[] allChildrenHelper(List<Transform> children)
{
foreach (Transform child in Children)
{
children.Add(child);
children = (List<Transform>)children.Concat(allChildrenHelper(children));
}
return children.ToArray();
}
/// <summary>
/// Gets all children of this game object.
/// </summary>
public Transform[] AllChildren => allChildrenHelper(new List<Transform>());
8 replies