调用某物体的子物体和子物体孙物体

 

public class UI_RingtButton : MonoBehaviour {

    public GameObject ZheZhao; 
    public GameObject Right_Canvas;

    public void JiChu_Button()
    {
        foreach(Transform child in Right_Canvas.GetComponentsInChildren<Transform>(true))    //调用子物体和孙物体
        {
            if (child.name == "jichu")
            {
                if (child.gameObject.activeSelf == true)
                {
                    child.gameObject.SetActive(false);
                }
                else
                {
                    child.gameObject.SetActive(true);
                }
            }
            if (child.name == "zuta")
            {
                child.gameObject.SetActive(true);
            }
            if (child.gameObject.name == "jiaxian")
            {
                child.gameObject.SetActive(true);
            }
        }


        foreach(Transform child in ZheZhao.GetComponent<Transform>())   //调用子物体
        {
            if(child.name== "JiChuMuLu")
            {
                if (child.gameObject.activeSelf == false)
                {
                    child.gameObject.SetActive(true);
                }
                else
                {
                    child.gameObject.SetActive(false);
                }
            }
            else
            {
                child.gameObject.SetActive(false);
            }
        }
    }

相关文章:

  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-30
  • 2021-07-28
  • 2022-12-23
  • 2021-11-09
  • 2021-07-25
  • 2022-12-23
  • 2021-05-30
相关资源
相似解决方案