Unity detects three children of the current object, but only grabs one

I have the following object:

169798-file.png

In a script attached to the TriggerableDoor1 parent object, I have the following start function:

   void Start()
    {
        Debug.Log("Child Count: " + transform.childCount);
        for (int i = 0; i < transform.childCount; i++) //Get the three children objects
        {
            Transform t = transform.GetChild(i);
            Debug.Log(t.name);
            if (t.name == "ClosedLoc" && _closeloc == null)
            {
                _closeloc = t.gameObject;
            }
            if (t.name == "OpenLoc" && _openloc == null)
            {
                _openloc = t.gameObject;
            }
            else if (t.name == "Door" && _door == null)
            {
                _door = t.gameObject;
            }

            _openloc.GetComponent<Renderer>().enabled = false; //Disable the renderers for the guides
            _closeloc.GetComponent<Renderer>().enabled = false;

        }
    }

I am attempting to get each of the object’s three children, and store them within the script. NOTE: This occurs whether I use a for loop with GetChild or foreach(Transform t in transform)

When I boot up the game, however, it only finds the first object in the list. It can be any of the three objects, but ONLY if they are the first listsed.

childCount returns three, however.

Here’s the actual debug output:

It only seems to ever want to grab the first object, despite the fact that it knows there are three.

What am I doing wrong?

I’m using Unity for Linux.

I checked your script and it returned all the 3 objects and disabled the openloc and closedloc, the default door is properly rendered.

public class UnityAnswersTest : MonoBehaviour
{
    [SerializeField] GameObject _openloc;
    [SerializeField] GameObject _door;
    [SerializeField] GameObject _closeloc;


    void Start()
    {
        Debug.Log("Child Count: " + transform.childCount);

        for (int i = 0; i < transform.childCount; i++) //Get the three children objects
        {
            Transform t = transform.GetChild(i);
            Debug.Log(t.name);

            if (t.name == "ClosedLoc" && _closeloc == null)
            {
                _closeloc = t.gameObject;
            }
            if (t.name == "OpenLoc" && _openloc == null)
            {
                _openloc = t.gameObject;
            }
            else if (t.name == "Door" && _door == null)
            {
                _door = t.gameObject;
            }
        }

        _closeloc.GetComponent<SpriteRenderer>().enabled = false;
        _openloc.GetComponent<SpriteRenderer>().enabled = false; //Disable the renderers for the guides
    }
}