How can you get what type object is? I'm looking at Panel and Image and they have almost the same view. How would I distinguished that mainMenu is a Panel and blankWindow is an Image, if I didn't know what is what? Panel:
Image:
CodePudding user response:
if(gameObjectToCheck.GetComponent<Rigidbody>() != null)
{
//do something
}
or more safe way:
if (gameObject.TryGetComponent(typeof(Rigidbody), out Component component))
{
//do something
}