
[Unity][C#]删除父物体所有含有特定组件的子物体
发布日期:2021-05-09 11:42:54
浏览次数:18
分类:精选文章
本文共 1339 字,大约阅读时间需要 4 分钟。
... /// /// ��������������������������������� /// /// ��������� public static void destoryChildGameObject(Transform trans_) { if (trans_ != null && trans_.childCount > 0) { for (int i = 0; i < trans_.childCount; i++) { GameObject.Destroy(trans_.GetChild(i).gameObject); } } }
... /// /// ���������������������������������������������componentName������������ /// /// ��������� /// ������������ public static void destoryChildGameObjectByCompontent(Transform trans_, string componentName) { if (trans_ != null && trans_.childCount > 0) { for (int i = 0; i < trans_.childCount; i++) { Component[] components = trans_.GetChild(i).gameObject.GetComponents(); // Debug.Log(i + " /// " + trans_.GetChild(i).name + "///" + componments2.Length); for (int j = 0; j < components.Length; j++) { // Debug.Log(i + " /// " + trans_.GetChild(i).name + "///" + componments2[j]); if (components[j].ToString() == trans_.GetChild(i).name + "(" + componentName + ")") { GameObject.Destroy(trans_.GetChild(i).gameObject); } } } } }
���������������
1. ...
2. ...
3. ...
发表评论
最新留言
表示我来过!
[***.240.166.169]2025年04月28日 11时52分45秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
LeetCode 947. 移除最多的同行或同列石头 并查集
2021-05-11
一些JavaSE学习过程中的思路整理(二)(主观性强,持续更新中...)
2021-05-11
JavaScript中如何给按钮设置隐藏与显示属性
2021-05-11
CSS——NO.4(继承、层叠、特殊性、重要性)
2021-05-11
Python——11面向对象编程基础
2021-05-11
Python——5函数
2021-05-11
C++中如何对单向链表操作
2021-05-11
C++走向远洋——63(项目二2、两个成员的类模板)
2021-05-11
6——PHP顺序结构&&字符串连接符
2021-05-11
C++扬帆远航——2
2021-05-11
C++扬帆远航——1
2021-05-11
上周热点回顾(5.3-5.9)
2021-05-11
测试网络联接状况常用命令 ping 使用方法介绍
2021-05-11
【python】Leetcode每日一题-设计停车系统
2021-05-11
【Bootstrap5】精细学习记录
2021-05-11
面试官:这些错误都没见过,还敢说会安装Elasticsearch?
2021-05-11
【Azure 应用服务】添加自定义域时,Domain ownership 验证无法通过
2021-05-11
归并排序
2021-05-11
Java复习面试指南02-JDK和JRE的区别?程序从源代码到运行经历哪几步?
2021-05-11
Java复习面试指南-06为什么要进行数据类型转换?什么情况下会进行自动类型转换?
2021-05-11