Keep pixels at a certain size

How can I keep the pixels in my sprite at exactly 8x8 pixels no matter how big or small the screen is?

You set the canvas scaler component on the canvas that contains the sprite to “Constant pixel size”.

@IvansArts If your sprite is already on a canvas, tanoshimi’s answer may work.

However, it probably isn’t already on a canvas. There are multiple ways to fix this, but I have done the following in the past:

  1. Create a render texture in your assets.
  2. Set the Camera to render to that render texture.
  3. Create a RawImage. (If you don’t have a UI yet, this will automatically create a canvas etc.)
  4. Set the RawImage’s texture to be the render texture.
  5. Now mess around with the Canvas’s scaler and the RawImage’s transform. (First try “constant pixel size” as tanoshimi suggested)

If you want it to adapt to the screen size or resolution, you will have to write code to do the above when it changes. I can’t quite remember the trick to it, but I have gotten it to work in the past.