Question regarding transform.getChild()

transform.GetChild(i).gameObject.SetActiveRecursively(true); = Is GetChild deprecated? Whats the replacement? Cant find getChild under transform.

If you are looking to traverse the scene tree, the Transform class is IEnumerable. That means that you can say something like:

foreach (Transform child in gameObject.transform){
   ...
}

If you wanted all of the children's children then the problem becomes a recursive one.

If it's components on children (like instances of MonoBehaviour scripts) that you are looking to get a hold of use the UnityEngine.Component.GetComponent... series of methods. You get back an array of the type of components that you requested that it finds.

transform itself is a container that contains the childs and as such would be the replacement and was it since U2

Why do you think it’s deprecated? It’s not. I’m not sure why they removed it from the documentation. Maybe it was never ment to be used manually. However the Transform IEnumerator uses GetChild internally, so they can’t remove it ;).

This is the enumerator object returned by Transform’s GetEnumerator:

private sealed class Enumerator : IEnumerator
{
    private Transform outer;
    private int currentIndex = -1;
    public object Current
    {
        get
        {
            return this.outer.GetChild(this.currentIndex);
        }
    }
    internal Enumerator(Transform outer)
    {
        this.outer = outer;
    }
    public bool MoveNext()
    {
        int childCount = this.outer.childCount;
        return ++this.currentIndex < childCount;
    }
    public void Reset()
    {
        this.currentIndex = -1;
    }
}