Search code examples
c#unity-game-engineclonechildren

How to enable a children of a clone object in Unity?


I hold my clones in a list for GUI operations in Unity3D & C#.

button = Instantiate(BlackBox, Vector2.zero, Quaternion.identity) as GameObject;
buttons.Add(button);

How to enable ArrowRight in this situation?

I want to reach ArrowRight to enable it. I tried variations of this kind of methods:

buttons[index].gameObject.transform.GetChild(1).gameObject.SetActive(true);

but it doesn't work. Objects' components.


Solution

  • Solved:

    instead of:

    buttons[index].gameObject.transform.GetChild(1).gameObject.SetActive(true);
    

    use:

    buttons[index].transform.GetChild(1).gameObject.SetActive(true);