Answers for "how to find the first parent object with tag unity"

C#
3

how to get parent gameobject in unity

childObject.transform.parent.gameObject
Posted by: Guest on December-14-2020
0

Unity search all chidren of parent object

using System.Collections.Generic;

private List<GameObject> listOfChildren;
private void GetChildRecursive(GameObject obj){
    if (null == obj)
        return;

    foreach (Transform child in obj.transform){
        if (null == child)
            continue;
        //child.gameobject contains the current child you can do whatever you want like add it to an array
        listOfChildren.Add(child.gameObject);
        GetChildRecursive(child.gameObject);
    }
}
Posted by: Guest on June-08-2021

Code answers related to "how to find the first parent object with tag unity"

C# Answers by Framework

Browse Popular Code Answers by Language