unity child code example
Example 1: unity access child
parentGameObject.transform.GetChild(0).gameObject
Example 2: unity get child
GameObject Child;
Child = transform.GetChild(0).gameObject;
Example 3: how to reference a child object unity
private void Start()
{
parentObject = GameObject.Find("Parent");
childObject = parentObject.transform.GetChild(0).gameObject;
}
Example 4: transform child
using UnityEngine;
using System.Collections;public class ExampleClass : MonoBehaviour
{
public Transform meeple;
public GameObject grandChild; public void Example()
{
meeple = this.gameObject.transform.GetChild(0);
grandChild = this.gameObject.transform.GetChild(0).GetChild(0).gameObject;
}
}