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

Question Pixel resizing (Scaling an object down, preserving pixel size)

Discussion in '2D' started by bbmcca26, Jun 2, 2023.

  1. bbmcca26

    bbmcca26

    Joined:
    May 21, 2023
    Posts:
    2
    Heyo. I've been playing around with pixel art for my game. My main concern is that all pixels in all objects across the game should be the same size. That's easy enough, but I like resizing objects at runtime (when they're spawned, asteroids have a chance to be scaled down to a random size. Their scale also decreases when damaged). I realized that, in Unity's game view, scaled down objects bunch up their pixels so the pixel size is preserved (see below). This is great because I don't have to draw a different sprite for each size! But when I build and run the HTML5 player, the pixel size is reduced along with the object, creating an effect that's not consistent with my game's blocky style. How do I make the effect consistent with the HTML5 player?

    HTML5 player, not what I want (pixels resized):

    Unity's game view, what I want (pixels bunched, pixel size preserved):


    Some info that might or not matter:
    - Every sprite is imported with a PPU of 64 (e.g. the ship is 64x64, therefore 1 unit big)
    - Filter mode is "Point (No filter)"
    - Compression is set to none
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,561
    Is this perhaps simply because WebGL is running at a much lower pixel size overall?

    To test it, find what res you're using in WebGL and make a Game window custom resolution of that size and see what gives when you run that in the editor.
     
  3. bbmcca26

    bbmcca26

    Joined:
    May 21, 2023
    Posts:
    2
    I set the WebGL resolution to 1024x512, which actually is the exact number of pixels in the view of the camera. I set that in the game view too, but it was just the same. As I was looking, though, I noticed an option that says "Low Resolution Aspect Ratios", unchecked it, and now it's the same as the WebGL. Apparently with that option checked, I get my desired effect, which is frustrating because I don't think that's an option under any build setting. I'm still trying to find a solution to this issue, which is weird because there already is one that does the job PERFECTLY but I think it's only a thing in the editor. I want to try everything before I hard code different sprites to match the asteroid size.
     
  4. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    i mean if thats all you want you can just use Screen.SetResolution