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

啤酒网站建设广告位招商怎么找客户

啤酒网站建设,广告位招商怎么找客户,注册一个设计公司需要多少钱,做返利网站能赚钱的我们寻找子物体,一般需要知道每个子节点,例子如下: 比如说,我需要找到CloseButton这个物体上的按钮组件,脚本挂在Canvas上,如果是用平常的方式来寻找的话: transform.Find("BG/Image/Clos…

我们寻找子物体,一般需要知道每个子节点,例子如下:

比如说,我需要找到CloseButton这个物体上的按钮组件,脚本挂在Canvas上,如果是用平常的方式来寻找的话:

transform.Find("BG/Image/CloseButton").GetComponent<Button>();

 需要使用这样一种方式来找寻,我觉得比较麻烦,于是写了一下遍历的工具。

先看代码:

using UnityEngine;/// <summary>
/// 
/// * Writer:June
/// *
/// * Data:2021.5.31
/// *
/// * Function:寻找物体的工具类
/// *
/// * Remarks:
/// 
/// </summary>namespace JuneLib.Utils
{public static class JuneTool{public static Transform FindMyChild(Transform parentTF, string childName){//在子物体中查找Transform childTF = parentTF.Find(childName);if (childTF != null) return childTF;//将问题交由子物体int count = parentTF.childCount;for (int i = 0; i < count; i++){childTF = FindMyChild(parentTF.GetChild(i), childName);if (childTF != null) return childTF;}return null;}public static Transform FindChildExpend(this Transform parentTF, string childName){//在子物体中查找Transform childTF = parentTF.Find(childName);if (childTF != null) return childTF;//将问题交由子物体int count = parentTF.childCount;for (int i = 0; i < count; i++){childTF = FindMyChild(parentTF.GetChild(i), childName);if (childTF != null) return childTF;}return null;}public static T FindChildCompomentExpend<T>(this Transform parentTF, string childName){return FindChildExpend(parentTF, childName).GetComponent<T>();}}
}

这是一个静态工具类,后面两个方法是扩展方法,可以直接使用,非常方便:

使用工具后,方便很多,即使不知道目标物体的父物体,都可以查找,不过需要注意的是,字符串的名字别填错!!!还有就是不可滥用,在父子层级非常多,并且子物体非常多的时候,就性能而言,还是不推荐使用这个方法。

transform.FindChildCompomentExpend<Button>("CloseButton");

 

http://www.wooajung.com/news/33673.html

相关文章:

  • 建设网站天河区成都网站制作关键词推广排名
  • wordpress添加音乐特效网站seo关键词优化技巧
  • 浙江智能建站系统价格网站托管
  • dede本地环境搭建网站国际新闻最新消息中国
  • 网站游戏入口网站seo最新优化方法
  • wordpress 多说 代码进一步优化营商环境
  • 黄页网站推广app免费下载网络推广营销网站建设专家
  • wordpress好主题seo网络排名优化哪家好
  • 宁波网站建设价格合理百度seo最新算法
  • 实时爬虫网站是怎么做的成都专门做网站的公司
  • 做网站3年西安优化外
  • 深南花园裙楼+网站建设bing搜索国内版
  • 做外贸常用的网站如何在百度上推广自己
  • 企业品牌网站建设方案seo整站优化一年价格多少
  • iis .htaccess wordpressseo如何优化网站步骤
  • 阿里云最新消息企业网站优化价格
  • 有没有学做零食的网站优化技术基础
  • 网站防护空间云搜索网页版入口
  • 网站建设的代码交易链接
  • ecshop 网站首页不显示怎么办网推资源渠道
  • 高唐网站建设服务商我要推广
  • wordpress加个留言板seo怎么优化效果更好
  • 企业站模板大全北京广告公司
  • 已经备案的域名做电影网站seo白帽优化
  • WordPress指定用户组可见株洲seo优化报价
  • 公司门户网站开发百度seo点击工具
  • 做网站须知百度搜索网
  • 网站开发助理是干啥的优化排名软件
  • 山东做网站建设的好公司品牌运营策略
  • 海南建设银行官网招聘网站网络口碑营销名词解释