Unity Find GetComponent
来源:互联网 发布:淘宝小二判定错误申诉 编辑:程序博客网 时间:2024/06/04 22:47
Unity提供了多种获得物体的方法,其中Find是效率最低的一种,我记得文档中应该有提到过尽量少用。
最快的获取物体的方法是直接引用:然后C#的GetComponent<T>系列函数应该是仅次于直接引用:GetComponent<T>; GetComponentInChildren<T>; GetComponentsInChildren<T>然后是FindWithTag; FindGameObjectsWithTag。虽然效率不及前者,但是通过Tag寻找物体是游戏中常用的手段,而且Unity内置了Tag系统,用起来很方便。
如果是在其子物体中寻找某一个类型(Class)的Component,GetComponentInChildren<T>是最佳选择,如果是在整个场景中搜寻某一种GameObject,基于FindWithTag从实用性和速度上都是很好的选择。
最快的获取物体的方法是直接引用:然后C#的GetComponent<T>系列函数应该是仅次于直接引用:GetComponent<T>; GetComponentInChildren<T>; GetComponentsInChildren<T>然后是FindWithTag; FindGameObjectsWithTag。虽然效率不及前者,但是通过Tag寻找物体是游戏中常用的手段,而且Unity内置了Tag系统,用起来很方便。
如果是在其子物体中寻找某一个类型(Class)的Component,GetComponentInChildren<T>是最佳选择,如果是在整个场景中搜寻某一种GameObject,基于FindWithTag从实用性和速度上都是很好的选择。
0 0
- Unity Find GetComponent
- Transform.Find();,FindObjectOfType<>();,GetComponent<>()
- Unity通过Attribute代替getComponent获取组件
- Unity学习笔记(四)-----------脚本、parent、GetComponent、GetComponentInChildren
- 关于Unity 获得和使用GetComponent<MeshFilter>().mesh时的心得
- unity3d GetComponent
- GetComponent优化
- Unity Shader.Find找不到
- Unity中的常用Find
- 剪切板Clipboard、SetComponent、GetComponent
- getComponent()方法的应用
- unity3d GetComponent函数
- GetComponent<T>()详解
- 尽量少用GetComponent
- JAVA-getComponent()与getSource()
- unity Find查找简单实用
- Unity中使用GameObject.Find、Transform.Find查找GameObject
- Unity Shader.Find 找不到内置shader
- 渐渐变成淡紫
- [Commons]效率篇之数组操作(ArrayUtils)
- mobile app market research
- Django学习笔记(二)—— 模板
- python操作mysql
- Unity Find GetComponent
- 练习一万小时
- centos启动后出现DMA错误解决方法
- STM32库函数EXTI_GetFlagStatus()和EXTI_GetITStatus()区别是什么?
- 在Eclipse中编译运行Android4.3应用源码——Launcher2和Gallery2
- Android的adb命令
- 黑马程序员-java关键字static详解
- 深入浅出TCP之半关闭与CLOSE_WAIT
- 配置secureCRT远程连接图形化显示