unity test if gameobject has component code example
Example: unity check if a gameobject has a component
if(gameObjectToCheck.GetComponent<Rigidbody>() != null) { //do something }
if(gameObjectToCheck.GetComponent<Rigidbody>() != null) { //do something }