I'm trying to find a way to move objects pixel-by-pixel(on my screen at least) in the scene editor. I tried a lot of different buttons but nothing seems to work, please tell me Unity has this functionality because doing it by mouse or by altering X and Y yourself is really tedious.

  • \$\begingroup\$ I'm not sure about the pixel by pixel movement but I know if you are looking to snap objects together you can hold down the "V" key and vertex snap the objects together... \$\endgroup\$ – Savlon Dec 8 '14 at 23:34
  • \$\begingroup\$ There is nothing as a pixel perfect placement. Because of varying screen size, resolutions and densities it makes no sense to move objects by pixels. Especially the transformation of the camera changes everything. \$\endgroup\$ – aggsol Dec 9 '14 at 8:56

I'm assuming you are working with 2D.

There is no pixel-by-pixel concept in the scene view, its a 3D evironment, and all positions are represented by Vector3s which have floating point components.

Your camera view, on the other hand, can be set up in such a way that everything appears pixel perfect. This link is slightly out of date (it was published before the Unity 2D workflow) so you can safely ignore everything about setting up the sprites and spritesheets. The important parts are:

Texture Filtering

If you’re going for the “pixel art” look, then it’s absolutely critical that you set your sprite textures to use Point filtering mode, not the default Bilinear. Point filtering preserves hard edges in the source texture, keeping your sprites nice and clean:

Filter Modes

Orthographic Size

The orthographic size expresses how many world units are contained in the top half of the camera projection. For example, if you set an orthographic size of 5, then the vertical extents of the viewport will contain exactly 10 units of world space. (The horizontal extents are dependent on the display aspect ratio.)

To render the pixel-art look cleanly, you need to ensure that each pixel of the sprite’s source texture maps 1:1 to the viewport display. You don’t want source pixels being skipped or doubled-up, or your sprites will look distorted and “dirty”. The trick to ensuring this 1:1 ratio is to set an orthographic size that matches your vertical screen resolution divided by the pixel height of a sprite.

Let’s say you’re running at 960x640, and you’re using 64x64 sprites. Dividing the vertical screen resolution (640) by the pixel height of a sprite (64) yields 10, the number of 64x64 sprites that can be vertically stacked in 640 pixels. Remember that the orthographic size is a half-height, so your target orthographic size in this case is going to be 5 (one-half of 10). It should look like this:

Clean Orthographic Size

If you set your orthographic size to half or double that target you may still get usable results, because the sprite’s vertical size will still divide evenly into the viewport’s vertical size. But if you set the orthographic size incorrectly, you will see some pixels skipped or doubled, and it will look very bad indeed:

Dirty Orthographic Size

| improve this answer | |

It seems that you are looking for a debugger, that is if you aren't linking with visual studio, otherwise visual studio should work. Just make sure you set the breakpoints at the correct lines of code, probably in your update method.

If you want to see the per pixel update in your editor, just simply start debugging, then view the values with public fields in the editor.


| improve this answer | |
  • \$\begingroup\$ The question is not debugging related but is about placement in the editor. \$\endgroup\$ – aggsol Dec 9 '14 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.