用户工具

站点工具


侧边栏

script:unityengine:classes:transform:transform.find

Transform.Find 查找

JavaScript ⇒ Find(name: string): Transform;
C# ⇒ Transform Find(string name);

Description 描述

Finds a child by name and returns it.

通过名字查找子对象并返回它。

If no child with name can be found, null is returned. If name contains a '/' character it will traverse the hierarchy like a path name.

如果没有查找到子对象名字,将返回null。如果名字包含“/”字符它将向路径一样穿越层次。

JavaScript:

	// The magical rotating finger
	function Update() {
		aFinger = transform.Find("LeftShoulder/Arm/Hand/Finger");
		aFinger.Rotate(Time.deltaTime*20, 0, 0);
	}

C#:

using UnityEngine;
 
public class Sample : MonoBehaviour
{
    Transform aFinger;
 
    void Start()
    {
        aFinger = transform.Find("LeftShoulder/Arm/Hand/Finger");
    }
 
    void Update()
    {
            aFinger.Rotate(Time.deltaTime*20, 0, 0);
    }
}

Transform

script/unityengine/classes/transform/transform.find.txt · 最后更改: 2016/08/02 05:37 (外部编辑)