Search Unity

Proper Values for Orthographic Viewport Rect and Pixels to Units

Discussion in '2D' started by RvBGames, Feb 15, 2014.

  1. RvBGames

    RvBGames

    Joined:
    Oct 22, 2013
    Posts:
    141
    Does anyone know how to get a 1:1 pixel mapping?

    What settings are needed for the Orthographic size?
    Settings for Viewport Rect?
    And settings for Texture Importer Pixels to Units?
     
  2. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    985
  3. RvBGames

    RvBGames

    Joined:
    Oct 22, 2013
    Posts:
    141
    Invertex thanks for the reply.

    I ended up setting the orthographic size to screenHeight / 2, and the viewport rect to (0, 0, screenWidth, screenHeight). And set Pixels to Units to 1. That appeared to work.

    Not sure that it works in all cases but just judging visually it does appear to work. Please let me know if there is some reason the above setup doesn't work.

    Thanks
     
  4. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    985
    One issue with that is having pixel to units = 1 will result in a MASSIVE scene scale. This is going to mean increased floating point inaccuracies, and if you're working with physics, more trouble there as well. Set pixel to 100 and divide your values by 100 (or multiply by 0.01 for better efficiency)

    The script I linked will dynamically adjust the ortho size depending on resolution set, so it's pretty handy.
     
  5. RvBGames

    RvBGames

    Joined:
    Oct 22, 2013
    Posts:
    141
    Thanks again Invertex.

    I'll come back to this thread shortly once we start working on our 2D game. We are currently using the setup described above for our menuing and thus far it appears to work correctly.
     
unityunity