Sprawdź, czy transformacja ma rodzica

if (transform.parent == null)
{

}
Mitch Soper