SetActiveRecursively(true) replacement in Uinity4.

When I use “gameobject.SetActive(true)” in unity 4, it just act like “gameobject.active = true” in unity3d 3.
How can I do “gameobject.SetActiveRecursively(true)” in unity 4?

Generally you’d use SetActive in Unity 4, but in those cases where you really need an exact replacement, then you can make your own function:

function SetActiveRecursively (go : GameObject, active : boolean) {
    go.SetActive (active);
    for (var t : Transform in go.transform) {
        SetActiveRecursively (t.gameObject, active);
    }
}

Here’s a version that lets you call it directly from a gameObject in c#:

public static class MyExtensions
{
    //bring this back to Unity4
    public static void SetActiveRecursivelyLegacy (this GameObject go, bool active) 
    {
        go.SetActive(active);
        foreach (Transform t in go.transform) 
        {
            t.gameObject.SetActiveRecursivelyLegacy(active);
        }
    }
}