unity3d GameObject.Find 严格区分大小写的

GameObject.Find 查找

 

static function Find (name : string) : GameObject

Description描述

Finds a game object by name and returns it.

If no game object with name can be found, null is returned. If name contains a '/' character it will traverse the hierarchy like a path name. This function only returns active gameobjects.

找到并返回一个名字为name的游戏物体。

如果以name为名字的游戏物体没有被找到,则返回空.如果name中包含'/'字符,这个名称将被视作一个hierarchy中的路径名.这个函数只返回活动的游戏物体。

For performance reasons it is recommended to not use this function every frame Instead cache the result in a member variable at startup or use GameObject.FindWithTag.

除非迫不得已,建议不要在每一帧中使用这个函数。可以在开始的时候用一个成员变量来缓存结果或者使用GameObject.FindWithTag函数。

注意:这里的参数name 是严格区分大小写的。

 

var hand : GameObject;
// This will return the game object named Hand in the scene.
//这将返回名为Hand 的游戏物体
hand = GameObject.Find("Hand");

// This will return the game object named Hand.
// Hand may not have a parent in the hierarchy view!
//这将返回名为Hand 的游戏物体,在层次视图中hand也没有父级物体
hand = GameObject.Find("/Hand");

// This will return the game object named Hand,
// which is a child of Arm -> Monster.
// Monster may not have a parent in the hierarchy view!
//这将返回Monster/Arm 的子级下名为Hand 的游戏物体,在层次视图中Monster也没有父级物体
hand = GameObject.Find("/Monster/Arm/Hand");

// This will return the game object named Hand,
// which is a child of Arm -> Monster.
// Monster may have a parent.
//这将返回Monster/Arm 的子级下名为Hand 的游戏物体,在层次视图中Monster可以有父级物体
hand = GameObject.Find("Monster/Arm/Hand");

 

 

 

 

转载于:https://www.cnblogs.com/fm168/p/3141656.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值