Element 3D musi posiadać na sobie Collider.
Camera.main możemy cachować do zmiennej.
GameObject activeObject;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
activeObject = hit.collider.gameObject;
}
}
}