Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

1 unit not mapping to grid

Discussion in '2D' started by dinamix13, Mar 25, 2021.

  1. dinamix13

    dinamix13

    Joined:
    Jan 3, 2021
    Posts:
    5
    I cannot understand why Unity is mapping position 1 in the transform to 8 units on the grid. This is a brand new project. I looked around to see if anyone has had similar problems or if there were settings to change the grid units but this doesn't seem possible. Does anyone have any ideas? I was expecting x = 1 to correspond to 1 grid unit.
     

    Attached Files:

  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,319
    This is likely from your Pixels Per Unit (PPU). Click on the sprite's texture in your Project and look at its settings. If the texture is 128x128 pixels then a PPU of 128 will be equivalent to 1 worldspace unit.
     
  3. dinamix13

    dinamix13

    Joined:
    Jan 3, 2021
    Posts:
    5
    I double checked that and I am using 100 pixels for a 100 x 100 and it is mapping the 100pixels to 8 units on the grid. I tried something similar with vector graphics and it is the same result. I included an image also with the camera as this is also happening with the camera. Unity seems to think that 1 unit is 8 units on the grid... is there anything that can be changed? Or is it possible that I changed a setting without realizing?
     

    Attached Files:

  4. dinamix13

    dinamix13

    Joined:
    Jan 3, 2021
    Posts:
    5
    I found that on the grid axis, you can access Edit Grid and Snap Settings and the grid was set to 0.125. Setting it to 1 makes the units change, however the scale stays the same. So the 100 pixel png file i posted above is scaled to the 1 unit once i change the settings but the 100 pixel svg file is not. As shown in the pictures I posted, if the svg is set to 25 ppu, then it matches the png 100 pixel setting. Does anyone know why all these units are scaled differently? Is it possible to make them match instead of having svg scaling different from a texture scaling?
     

    Attached Files:

  5. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    svg files are dynamic and dont have a base size they maintain resolution at any zoom lvl, that being said svg are meant for print and not for digital, so you should stick to rasterized graphics in unity
     
  6. dinamix13

    dinamix13

    Joined:
    Jan 3, 2021
    Posts:
    5
    Is there a reason you say svg should not be used for digital? I see them as a good solution for static images since they scale at any size for any screen. Or does the cost of rendering vector graphics surpass rasterized by too much to justify it for a 2d game?

    Also, what do the ppu represent for the svg importer in unity then? About Vector Graphics | Vector Graphics | 2.0.0-preview.14 (unity3d.com) it says "Number of SVG units that correspond to 1 scene unit." I tried changing the height and width within the svg xml file but this did not change anything. Does anyone know if Unity is using an arbitrary "svg unit" or if it is in fact related to something in either svg or unity?
     
  7. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    I say it because vector graphics will always be converted to raster graphics when you use them in unity, so you might aswell use raster from the start

    vector graphics exist specifically for their use in physical printing, vector graphics will always display the same quality on print no matter the size of the surface they are printed on, this avoids pixelization in billboards, etc. In digital form you are always displaying pixels so vector graphics have diminishing returns, and may even hinder you on what you want to achieve.
     
  8. dinamix13

    dinamix13

    Joined:
    Jan 3, 2021
    Posts:
    5
    Cool thanks! Good to know :) so would a good general method be to use high resolution rasterized images (say like 4k +) and then let unity downscale it to maintain decent resolution?
     
  9. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    yes that would be a better approach, for downscaling you should do it in photoshop because it yields better results, depends on how you are using the images