Search Unity

ScreenToWorldPoint acting differently on a Mac compared to a PC

Discussion in 'Editor & General Support' started by JeffersonTD, Jan 25, 2017.

  1. JeffersonTD

    JeffersonTD

    Joined:
    Feb 5, 2013
    Posts:
    268
    I have set up some editor tools for helping in doing some level editing. I mostly work on a PC, but then at least to do iOS builds I open the project on a mac. But there is one thing that seems to behave differently on the mac. Getting the coordinates within the scene seem to work in the same fashion, but when I call

    camera.ScreenToWorldPoint(posInScene)

    on Windows the correct position is returned but on the mac it returns something entirely different. What could be the reason for this? And how could I fix this? I'm doing this in OnSceneGUI.

    A possibly related thing I've noticed is that for some weird reason camera.rect is always camera.rect(x:0.00, y:0.00, width:1.00, height:1.00) on PC, but on a mac for "Layout" events it's (x:0.00, y:-0.99, width:2.00, height:2.00). Could someone explain that? :confused:
     
  2. JeffersonTD

    JeffersonTD

    Joined:
    Feb 5, 2013
    Posts:
    268
    Has someone had similar experiences or have an idea why eg on the Mac the camera.rect is different for the Layout event?
     
  3. JeffersonTD

    JeffersonTD

    Joined:
    Feb 5, 2013
    Posts:
    268
    No one's had the same issue?
     
  4. tarasrng

    tarasrng

    Joined:
    May 18, 2017
    Posts:
    11
    I have the same issue with Camera.current.ScreenPointToRay.
    Have you found what's wrong?
     
  5. tarasrng

    tarasrng

    Joined:
    May 18, 2017
    Posts:
    11
    I found the the workaround: use HandleUtility.GUIPointToWorldRay instead of camera.ScreenToWorldPoint.
     
    JeffersonTD likes this.
  6. JeffersonTD

    JeffersonTD

    Joined:
    Feb 5, 2013
    Posts:
    268
    I actually moved on to another project, and also primarily working on a PC, it's not that important, so I didn't find a solution.

    But thanks for sharing your finding! That might come in handy if I do something similar or some day return to that earlier project!