出于性能原因,建议不要每帧都使用此函数,而是在启动时将结果缓存到成员变量中,或者使用 GameObject.FindWithTag。Note: If you wish to find a child GameObject, it is often easier to use Transform.Find. using UnityEngine; using System.Collections;public class ExampleClass : MonoBehaviour { public ...
所以说要做到性能最佳的查找应该将GameObject.Find(string name)和Transform.Find(string path)和Transform.GetChild(int index) 和GameObject.FindGameObjectWithTag(string tag)几种方式根据需求相结合 1.当GameObject.Find(string name) 查找条件不受限制时,用GameObject.Find 2.当查找数量不多,且需要包含隐藏物体时,...
GameObject.FindWithTag 查找标签 返回一个用tag做标识的活动的游戏物体,如果没有找到则为空。标签必须在使用之前到标签管理器里面声明。 GameObject.FindGameObjectsWithTag 查找标签的游戏物体列表 返回一个用tag做标识的活动的游戏物体的列表.如果没有找到则为空。标签必须在使用之前到标签管理器里面声明。 Resources....
For performance reasons, it is recommended to not use this function every frame. Instead, cache the result in a member variable at startup. or useGameObject.FindWithTag. Note: If you wish to find a child GameObject, it is often easier to useTransform.Find. 例: using UnityEngine; using S...
Transform类下公有函数,Unity文档对此函数的描述如下:Finds a child by namenand returns it.If no ...
Unity怎么获得子..Unity怎么获得子物体我用Transform.FindChild("子物体路径").transform提示我这个方法过时了,那现在用什么方法啊,百度不到啊,有没有大佬告我怎么用
因为这个函数已经取消了FindChild,改成了Find示例如下:假设场景中有一物体:player/body(名为plyer,有一子物体body)原FindChild函数:transform.FindChild("body");Find函数:transform.Find("player/body");区别就是Find函数需要将物体层级标示清楚,而FindChild则是直接使用子物体名作参数 ...
unity:unity 在场景中查找物体 = this.transform.GetChild(0); //获取第一个子物体 括号里面只能是int类型,不激活也可以Transformname1 = this.transform.Find("... =transform.Find("Cube");//这个跟transform.find一样 本人用的是2018.3.0 这个方法已经舍弃但是可以用 Debug.Log ...
Find() does not find the third child. // ExampleClass has a GameObject with three spheres attached. // Two of these are children of the GameObject. The third // transform, sphere3, is a child of sphere2. Find() does // not find this child.using UnityEngine;public class ExampleClass...
在这个问题被问到的这些年里,Unity提供了你所需要的东西。至少,我所需要的东西。在这里为未来的人们...