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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question How to get the next Pixel Perfect Orthographic Size

Discussion in 'Cinemachine' started by Jamisco, Dec 2, 2022.

  1. Jamisco

    Jamisco

    Joined:
    May 21, 2022
    Posts:
    4
    My object has the Cin machine pixel perfect component added to it
    I have a pretty simple zooming script here. When the user zooms in/out change the orthographic size

    Code (CSharp):
    1.                
    2.  
    3.                 mapVirtualCamera.m_Lens.OrthographicSize = newOrtho;
    4.                 cameraBrain.ManualUpdate();
    5.  
    however, if the new OrthographicSize is not pixel perfect, when you update the camera, the camera will not switch to the new orthographicSize as expected.

    How can I get the next pixel perfect orthographicSize?

    I know I can use a loop and then check if the main camera orthographicSize changes, but that would require multiple manual updates which I rather not do.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,267
    Cinemachine itself tries to remain agnostic about PixelPerfect. The idea is that the (non-Cinemachine) PixelPerfect behaviour on the main camera will round the desired ortho size to the nearest PP ortho size. The CinemachinePixelPerfect component accesses an API in the (non-Cinemachine) PixelPerfect component to get the rounded size:
    PixelPerfectCamera.CorrectCinemachineOrthoSize()
    .
     
    Jamisco likes this.
  3. Jamisco

    Jamisco

    Joined:
    May 21, 2022
    Posts:
    4
    Thank you very much, this is exactly what I was looking for.
    I was looing for such a method in the Pixel Perfect camera class from cinmachine library, meanwhile it was in the pixel perfect camera from UnityEngine.U2D
     
    Gregoryl likes this.