Enable and disable Children gameobject c #

0

Well, I made a script where it activates and deactivates in the gameobject , I wanted to know how to activate and deactivate the children also inside this script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class OBJETOS : MonoBehaviour
{
    public GameObject[] arrayObjetos;

    public void botoes(int num)
{
    for(int i = 0; i < arrayObjetos.Length; i++)
{
    if( arrayObjetos[num] == arrayObjetos[i])
{
    arrayObjetos[i].SetActive(true);
    }else{
    arrayObjetos[i].SetActive(false);
}
}
}
}
//sei que pode ser assim GameObject meuobjeto = GameObject.Find("meuobjeto");
// e assim tbm GameObject ChildGameObjeto1 = ParentGameObject.transform.GetChild (0).gameObject;
    
asked by anonymous 12.09.2017 / 22:34

1 answer

0

This disables all children of the gameObject as you put the script:

    foreach (Transform t in transform)
    {
          t.gameObject.SetActive(false);
    }
    
12.09.2017 / 22:40