200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > unity通过脚本获取一个物体的所有子物体孙子物体.....并从里面找到有动画的物体

unity通过脚本获取一个物体的所有子物体孙子物体.....并从里面找到有动画的物体

时间:2022-07-12 07:21:09

相关推荐

unity通过脚本获取一个物体的所有子物体孙子物体.....并从里面找到有动画的物体

public Transform[] grandFa;public List<GameObject> animObs = new List<GameObject>();public int indexAnim = 0;// Use this for initialization void Start(){grandFa = GetComponentsInChildren<Transform>();//打到所有的子孙子物体//get all objects of having animator, that is there is no childforeach (Transform child in grandFa){//找到最下一层的子节点,以及子节点上有动画的物体if (child.childCount == 0 && child.gameObject.GetComponent<Animator>()){animObs.Add(child.gameObject);child.gameObject.GetComponent<Animator>().enabled = false;}}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。