Screen size and camera problem not match

My game need to fix camera fit to game and I will create sprite to fit screen same.
I settings display screen to 640x360 is 16:9
8732511--1181955--upload_2023-1-16_4-24-4.png

and I create sprite 640x320 size (Setting Pixel Per Unit : 32 ) import to my unity
and then I come to screen found some problem my sprite bigger more than screen or camera,

If I count 1 grid is 32 pixel like (Setting Pixel Per Unit : 32 ) my sprite is 20 grid result 20*32 = 640 pixel is right
but camera is look like around 17.8 *32 = 569 pixel,look like small than my sprite. I don’t understand why problem here.

I try get sprite size, screen size it same size. and camera size

   SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer>();
        Debug.Log($"sprite size # {spriteRenderer.sprite.rect.width}, {spriteRenderer.sprite.rect.height}");
      
        Camera cam = Camera.main;
        float height = 2f * cam.orthographicSize;
        float width = height * cam.aspect;
        Debug.Log($"Camera # {width}, {height}");


        Debug.Log("Screen Size : " + Screen.width + "," + Screen.height);

8732511--1181967--upload_2023-1-16_4-33-17.png
this finally detail, I so confuse about this. Please help me to understand something, i try read document but not clear to my problem. I want to set screen and camera to correct size what I want and create sprite for fit to it from art program.

Thank you.
Ps.Sorry for my english, I can’t typing not strong too much


8732511--1181967--upload_2023-1-16_4-33-17.png

The screen size you select in the scene view only affects the screen size (duh), how that translates into what you’re camera is seeing and how many world units are visible is dependent on the camera settings and entirely unrelated to screen size.

You need to adjust your camera’s orthographic size to fit your sprite. If your sprite is 11.25 units high (360 / 32), your orthographic size needs to be half of that, so 5.625. From the console output it looks like it’s currently set to 5 and therefore cuts off part of the sprite.

Note that it’s often not possible to dictate screen/window size (e.g. on mobile), so it’s usually better to dynamically adjust your camera to render only to a part of the screen (i.e. letterboxing) to make sure only a set viewport is visible at all times.

thank you for reply.Now I understand how it work.