Search Unity

[Released]Pixel Perfect Camera

Discussion in 'Assets and Asset Store' started by Douvantzis, Jul 15, 2016.

  1. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    So, I'd need to use PPC to keep the pixels accurate, but how would I post-process that by stretching the output if PPC is already filling the view?
     
  2. SamFZGames

    SamFZGames

    Joined:
    Mar 2, 2014
    Posts:
    52
    Hey guys, for some reason if I set my camera to move on LateUpdate() (which I'd say is pretty important), PixelPerfect Camera causes it to completely bug out, the Camera doesn't update until I switch to Scene view and back again.

    EDIT: I fixed this by putting the PixelPerfectCamera script late on in the Script Execution Order inspector.
     
    Last edited: Nov 28, 2017
  3. Robosaur

    Robosaur

    Joined:
    Jan 21, 2014
    Posts:
    6
    How would you go about implementing a "minimum height" so that if the screen is too small, it compensates by disabling pixel perfect, while still trying to make the game window the target height in units? While my game should only require 640 pixels vertically, the unity peripherals take up enough space that the window becomes only 600 pixels tall...
     
  4. Douvantzis

    Douvantzis

    Joined:
    Mar 21, 2016
    Posts:
    79
    This is a feature I am thinking of implementing at some point.

    For the time being, you could edit PPC to do that. An alternate approach would be to make a script that controls PPC and do what you want. Please read the last section of the readme "Instructions for scripts interacting with.. " regarding reading values from PPC. You can then call the "setter" methods to toggle "pixel perfect" mode.
     
  5. nikitabuyevich

    nikitabuyevich

    Joined:
    Feb 17, 2018
    Posts:
    1
    Hi, I am having a couple of issues.

    I'm having trouble understanding what to set the "Assets Pixels Per Unit" to. Is it the resolution of my files? For example if my project is mostly 32 x 32, do I set it to 32?

    So I go ahead and do that for my simple starter project and I create a tilemap which has tiles of size 32 x 32. However, the camera is slightly bigger than the grid that was created. How can I fix this and get it perfectly aligned? (besides stretching the grid to make it work).

    I've included the simple project to demonstrate what I'm talking about.
    https://ufile.io/mee93

    Also if I wanted to zoom out in my game, I am no longer able to do that if I want to keep the game pixel perfect, correct?
     
  6. Dryn27

    Dryn27

    Joined:
    Dec 10, 2016
    Posts:
    11
    Hi, is it possible to add a bool to the camera so it moves snapped to the grid??
     
  7. Back_To_Jakku

    Back_To_Jakku

    Joined:
    Mar 29, 2018
    Posts:
    1
    Hi, im curious how I would go about having sprites with different sizes in the project. I have my actor sprite that is 32x32, my tiles which are 16x16 and my weapon sprite which i want to be very detailed is 64x64. Now in the PixelPerfectCamera script i have the asset PPU set to 16 and it works fine for the character and tiles because i want the character to be bigger than one tile, but this makes my weapon sprite huge and if i put its PPU at 64 it makes it very distorted. I would appreciate any help on this subject.
     
  8. Douvantzis

    Douvantzis

    Joined:
    Mar 21, 2016
    Posts:
    79
    @Back_To_Jakku Being pixel perfect implies that all your assets have the same ppu and no scale. There's no getting around that. Otherwise, you would end up having different pixel densities for each asset.
     
  9. Douvantzis

    Douvantzis

    Joined:
    Mar 21, 2016
    Posts:
    79
    You could try enabling the retro mode.
     
  10. Douvantzis

    Douvantzis

    Joined:
    Mar 21, 2016
    Posts:
    79
    Please read previous answers to the thread.

    "Assets Pixels per Unit' is the "pixels per unit" number that you use for your textures. It must be the same for all of them.

    Due to the way that pixel-perfect works, the zoom may vary. You can't have exactly the zoom level you want. There are options in Pixel Perfect Camera to get as close as possible to the desired zoom (target size) or even set restrictions. I have given a more detailed explanation of this in previous answers.
     
  11. Cilerba

    Cilerba

    Joined:
    Dec 12, 2016
    Posts:
    6
    Hello. After updating to 2018.3.0f2, I've started running into a strange issue where the Canvas Screen Space Scaler script will not work when running at a higher resolution than the native resolution (in my case 640x360).

    It will temporary scale the canvas if I disable + enable the script, however, it will go back to a scale factor of 1 when playtesting/exiting playtesting.

    I've tried manually calling AdjustCanvas() as well and that doesn't increase the scale factor like it did normally before the 2018.3 update. Any ideas what could be causing this? Thanks!

    EDIT: Changing the Canvas Scaler's scale factor directly instead of the Canvas' scale factor seems to work.
     
    Last edited: Dec 18, 2018