Transform.Find()
代码演示:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TransformFind : MonoBehaviour {
private Transform m_Transform;
private GameObject one;
private GameObject two;
void Start () {
m_Transform = gameObject.GetComponent<Transform>();
one = m_Transform.Find("D2").gameObject;
two = m_Transform.Find("D2/D3").gameObject;
Debug.Log(one.name);
Debug.Log(two.name);
}
}
---------------------