unity check if child exists
Transform[] ts = GetComponentsInChildren<Transform>();
foreach(Transform t in ts)
{
if(t != null)
{
//do something
}
}
unity check if child exists
Transform[] ts = GetComponentsInChildren<Transform>();
foreach(Transform t in ts)
{
if(t != null)
{
//do something
}
}
c# unity check if gameobject has child
// 1
if(transform.childCount > 0) //do something
// 2
for (var child : Transform in transform) {
// do whatever you want with each child transform here
}
// 3
for(var i : int = 0; i < transform.childCount; i++) {
var child : Transform = transform[i];
// do whatever you want with each child transform here
}
// 4
for(var something : Thing in somethingElse) {
// do whatever you want with each something here
}
// 5
for(var i : int = 0; i < somethingElse.length; i++) {
var something : Thing = somethingElse[i];
// do whatever you want with each something here
}
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