how to get parent gameobject in unity
childObject.transform.parent.gameObject
how to get parent gameobject in unity
childObject.transform.parent.gameObject
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);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us