Use mouse as stylus (stylus emulation)

To improve testability in the Unity editor (specially for some technical artist who doesn’t have all the hardware), I wrote some code to encapsulate the stylus behavior into a class PointerInput.

This class has two subclasses with a mouse and a stylus implementation.

For the mouse implementation, I will asume that the emulated stylus would be pointing perpendicular towards the screen, and X centimeters away from the screen. I’m using the following code to create a Pose:

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

_pose = new ZCore.Pose (ray.origin, Quaternion.LookRotation (ray.direction), Time.time, ZCore.CoordinateSpace.World);

But this is not working because it’s making the calculations using the camera’s original frustum.

Any ideas on how to achieve this?

ohhh just found the ZCore.ScreenPointToRay method :smiley: