Set Objects Child to Active/Inactive(Solved)

Part of my script allowed for a gameObject to be set active/inactive depending if it was selected(or not)

		// Activate/Deactivate the game object/child.

Things have changed a little now and that gameObject has a single child that I now want to make active/inactive. There seems to be so many conflicting ideas about how to do this its confusing.

Whats the simplest way to access the child object and deactivate it. (The parent object is always active)




My answer, glad that it helps you

private var childObj : Transform;
 function Start () {
   childObj = transform.Find("Child Name");
 function Update () {
   if (selected){ = true;


if (selected)
theChild.SetActive(true); // Activate
theChild.SetActive(false); //Deactivate

I have 3 GameObjects namely red, blue and green, and each has children objects named A1, A2, A3…A100. (all 3 objects have children of the same name).

How do I disable one specific object? Say A5 of Red, and A7 of Blue.

I actually came up with a solution based on your suggestion.

private var lightRing : Projector;
    function Start ()
        lightRing = GetComponentInChildren(Projector);
    		lightRing.enabled = true;