unity check if gameobject is in parent or grandparent code example Example: check if object has parent unity if(transform.parent != null) { }