Search Unity

PixelPerfectRendering make exceptions for specific renderers?

Discussion in '2D' started by Necronomison, Mar 14, 2021.

  1. Necronomison

    Necronomison

    Joined:
    Mar 14, 2021
    Posts:
    1
    Hi there!

    So I'm using calls to "PixelPerfectRendering.pixelSnapSpacing" to make sure that all my sprites snap to my specified PPU. I do this very much like the PixelPerfectCamera via the OnPreRender and OnPostRender calls:


      void OnPreRender()
    {
    // Clear the screen to black so that we can see black bars.
    // Need to do it before anything is drawn if we're rendering directly to the screen.
    if (snapEnabled)
    {
    PixelPerfectRendering.pixelSnapSpacing = 1.0f / ppu;
    }
    }

    void OnPostRender()
    {
    if (snapEnabled)
    {
    PixelPerfectRendering.pixelSnapSpacing = 0.0f;
    }
    }


    Now, as for my question: is there anyway to allow certain sprite renderers to not adhere to this (ie dont snap?). I know that these are operations done on pre render / post render, so would I have to basically re-implement whatever PixelPerfectRendering does in order to this?

    Any help would be greatly appreciated. Thank you!