删除所有子物体保留父物体的2种方式

来源:互联网 发布:rc4算法原理图 编辑:程序博客网 时间:2024/06/11 01:43
  1. using UnityEngine;  
  2. using System.Collections;  
  3. /// <summary>  
  4. /// 脚本位置:将此脚本挂载到父物体A身上  
  5. /// 脚本功能:用于测试销毁所有子物体  
  6. /// </summary>  
  7. public class Parent : MonoBehaviour  
  8. {  
  9.   
  10.     void Start ()  
  11.     {  
  12.         for (int i = 0; i < transform.childCount; i++) {  
  13.             Destroy (transform.GetChild (i).gameObject);  
  14.         }  
  15.     }  
  16.   
  17. }  
http://blog.csdn.net/sinat_20559947/article/details/48269245
阅读全文
0 0
原创粉丝点击