Search Unity

Manually Set Sprite pixelsPerUnit

Discussion in '2D' started by CalaveraX, Oct 24, 2014.

  1. CalaveraX

    CalaveraX

    Joined:
    Jul 11, 2013
    Posts:
    143
    Hi Guys

    I'm making a grid for a tiled scenario, the problem is that i'm loading all my textures from code, and creating sprites in runtime. It seems like unity is making it with a pixels per unity of 100.

    i would need to set it to 1, because when i try to order them, if i multiply per width and heigth, my grid get all spreaded out one tile faaaar away from the next :(
     
  2. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
    Hi,

    Sprite.Create has a pixelstounits argument. Set that to whatever you need.
    However it should not matter what your value is, you should still be able to grid tile your sprites.
     
  3. CalaveraX

    CalaveraX

    Joined:
    Jul 11, 2013
    Posts:
    143
    Cool! Thanks!

    now i have two solution to this.
    What i was doing was separate my sprites by the texture.width, but because the pixeltounits it was being al tiled one apart from another, the solution was only to do a texture.widtg / pixeltounits.

    Cheers!