当前位置: 首页 > news >正文

怎么建设一个电影网站html5 企业 网站

怎么建设一个电影网站,html5 企业 网站,百度怎么免费推广自己的产品,域名大全查询本文总结一下关于unity的查找子物体的方法 首先说明一下这里将讲三种查找子物体方法#xff1a; 查找固定路径的某一个子物体的方法、通过名字深度查找某个子物体的方法、查找父物体下所有子物体的方法。 第一:查找固定路径的某一个子物体的方法 对于已知的路径可以直接用go.t… 本文总结一下关于unity的查找子物体的方法   首先说明一下这里将讲三种查找子物体方法 查找固定路径的某一个子物体的方法、通过名字深度查找某个子物体的方法、查找父物体下所有子物体的方法。   第一:查找固定路径的某一个子物体的方法 对于已知的路径可以直接用go.transform.FindChild方法来查找。 例如在这样一个层级路径下我们要找到最后那个plane物体。   1 using UnityEngine;2 using System.Collections;3 4 public class findchild : MonoBehaviour {5 6 // Use this for initialization7 void Start () {8 9 } 10 11 // Update is called once per frame 12 void Update () { 13 if (Input.GetMouseButtonDown(1)) 14 { 15 //查找物体方法 16 GameObject go GameObject.Find(Cube); 17 //查找子物体并且将得到的物体转换成gameobject 18 GameObject objname go.transform.FindChild(Sphere/Cylinder/Plane).gameObject; 19 20 Debug.Log(得到最终子物体的名字是 objname.name); 21 } 22 } 23 }   然后是执行结果       -------------------------------------------------------------------------------------------------------------   第二通过名字深度查找某个子物体的方法 注意要使用这个方法必须要满足两个条件第一必须有你要查找的子物体的名字第二必须要从一个父物体上开始查起     下面代码中check代表从这个父物体开始查起name为你要查找的目标子物体的名称。如return GetTransform(transform,bone12); 该方法核心代码     而下面是查找的具体方法 1 Transform GetTransform(Transform check, string name)2 {3 Transform forreturn null;4 5 foreach (Transform t in check.GetComponentsInChildrenTransform())6 {7 if (t.name name)8 {9 Debug.Log(得到最终子物体的名字是 t.name); 10 forreturn t; 11 return t; 12 13 } 14 15 } 16 return forreturn; 17 }   再看完整的测试代码还用上个的例子的例如这次要查到Cylinder这个物体   修改后的代码 1 using UnityEngine;2 using System.Collections;3 4 public class findchild : MonoBehaviour {5 6 // Use this for initialization7 void Start () {8 9 } 10 11 // Update is called once per frame 12 void Update () { 13 if (Input.GetMouseButtonDown(1)) 14 { 15 // //查找物体方法 16 GameObject go GameObject.Find(Cube); 17 // //查找子物体并且将得到的物体转换成gameobject 18 //GameObject objname go.transform.FindChild(Sphere/Cylinder/Plane).gameObject; 19 20 //Debug.Log(得到最终子物体的名字是 objname.name); 21 22 23 GetTransform(go.transform, Cylinder); 24 25 } 26 } 27 28 Transform GetTransform(Transform check, string name) 29 { 30 Transform forreturn null; 31 32 foreach (Transform t in check.GetComponentsInChildrenTransform()) 33 { 34 if (t.name name) 35 { 36 Debug.Log(得到最终子物体的名字是 t.name); 37 forreturn t; 38 return t; 39 40 } 41 42 } 43 return forreturn; 44 } 45 }   测试结果   ----------------------------------------------------------------------------------------------------- 第三接下来我们将获取一个父物体下的所有子物体,然后销毁其下所有子物体 注意所有子物体都是同级关系在同一层里。如图   核心方法 1 ListTransform lst new ListTransform();2 foreach (Transform child in transform)3 {4 lst.Add(child);5 Debug.Log(child.gameObject.name);6 }7 for (int i 0; i lst.Count; i)8 {9 Destroy(lst[i].gameObject); 10 }   上面的transform就是该父物体的transform。具体案例代码 1 using UnityEngine;2 using System.Collections;3 using System.Collections.Generic;4 5 public class findchild : MonoBehaviour {6 7 // Use this for initialization8 void Start () {9 10 } 11 12 // Update is called once per frame 13 void Update () { 14 if (Input.GetMouseButtonDown(1)) 15 { 16 // //查找物体方法 17 GameObject go GameObject.Find(Cube); 18 ListTransform lst new ListTransform(); 19 foreach (Transform child in go.transform) 20 { 21 lst.Add(child); 22 Debug.Log(child.gameObject.name); 23 } 24 for (int i 0; i lst.Count; i) 25 { 26 Debug.Log(销毁的物体是 lst[i].gameObject); 27 Destroy(lst[i].gameObject); 28 } 29 30 } 31 } 32 33 34 } 测试结果全被销毁了     以上就是我总结的常用的三种查找子物体的方法。   转载于:https://www.cnblogs.com/macky/p/9335093.html
http://www.zqtcl.cn/news/621904/

相关文章:

  • 网站优化需要什么软件有没有帮别人做网站
  • 做国外网站选择vps汉中公司做网站
  • ipad网站开发百度推广送的公司网站有什么用
  • 网站被收录wordpress模板游戏推广
  • 做个网站成功案例深圳网络推广工资
  • 河南省城乡与住房建设厅网站做网站的都是什么专业毕业的
  • 做网站月薪10万微信网页开发教程
  • 网站开发组岗位上海著名企业
  • 阿里云网站建设方案网站源码分享
  • 设计感很强的中文网站公司专业网页制作
  • 自己制作网站做外贸赚钱吗什么是网站html静态化
  • 网站中的搜索功能怎么做的网站空间价格
  • 网站内容收费WordPress之类的
  • 好网站推荐一下网站建设客户评价
  • 重庆交通网站建设wordpress08模板
  • 网站搭建响应式wordpress访客切换主题
  • 标准网站建设推荐帮别人做网站开票开什么税目
  • 温州网站优化衡阳县专业做淘宝网站
  • 门户网站建设存在的问题和差距无锡做智能网站
  • 受欢迎的常州做网站网站制作ppt
  • 物流网站建设实例 天堂资源帝
  • 太原建设厅官方网站wordpress 导入工具
  • 做网站树立品牌形象建设了网站后怎么用谷歌引流
  • 专业公司网站建设建设人才库网站
  • 怎么自己做直播网站吗手机免费建站app
  • 惠州规划建设局网站seo网站关键词排名优化公司
  • 关键词检测百度seo一本通
  • 做效果图的外包网站徐州低价seo
  • xp系统中做网站服务器吗网站设计版权
  • 化妆品网站建设经济可行性分析怎么做好网站