Welcome, Guest

Author Topic: How to get correct mouse input coordinates  (Read 1227 times)


  • Coherent Labs support
  • Administrator
  • *****
  • Posts: 205
    • View Profile
How to get correct mouse input coordinates
« on: February 08, 2016, 05:05:07 AM »
Hello Devs,

We have had a lot of people struggling with misaligned input in Coherent Views. Mike has answered such questions a few times, but it seems that his answer will need some more visibility :)

There is a utility script in our samples called ObjectPicker.cs. It translates the mouse coordinates from the 3D mesh to the page view. You could check it for reference and implement it in your application or you can just attach it to a game object as is.

The misalignment is caused by the different ways in which Coherent UI and Unity3D map textures. Unity3D treats the lower left corner as the (0, 0) point whereas Coherent UI treats the upper left corner as the (0, 0) point. Mouse input uses texture coordinates. If you check the Flip Y checkbox of the view component it only flips the rendering coordinates, but does not flip the texture and the texture coordinates stays the same.

To flip the texture you can set the Transform Scale's Z of the Plane to -1. Alternatively you could use our back_face mesh which has appropriate UV coordinates or make one yourself.


Tags: input mouse unity unity3d