Right now there is no way to do a 3D raycast when 2D physics is used. A lot of use cases for this, using it for input detection when using perspective camera is one.
This might be a symptom of a different thing: you can’t run both physics engines at the same time. Being able to have the gameplay physics run in 2D, but have certain effect physics run in 3D is one use case.
Preferably there would be different colliders for the different physics engines, and two modules to interface with them (physics2d and physics3d) rather than just one that switches behaviour based on project settings (physics). Especially if you write code in a libraray it is hard to do that if the behaviour changes when the user switches physics engine.