I have an object’s transform from a raycast, and I would like to know what type of object I hit. Is there any way to tell? I have tried an expression like:
Type t = hit.collider.transform as Type
then testing to see if t is null, but I get a compiler error in the upcast.
Edit: To explain further, I have several types of objects in the scene. When the mouse is clicked, I am determining which object was clicked using a raycast from the screen. Different objects behave differently when clicked, so I need to know what type of object was clicked to know what to do with it, and I will need a reference to the object (not just its transform) to be able to call the appropriate methods on it.