Main Camera Orthographic doesn't work after build

Hello, I’m newbie with Unity3D.

I want to change my main camera’s projection “Perspective” to “Orthographic”.

then i use this code for this work, very simple

 public void persp_ortho_Btn_Clicked()
{
     if (!Camera_Controller.shared_instance.isOrthoCamera)
     {
         Camera_Controller.shared_instance.isOrthoCamera = true;
         Camera.main.orthographic = true;
         ui_camera.orthographic = true;
     }
     else
     {
         Camera_Controller.shared_instance.isOrthoCamera = false;
         Camera.main.orthographic = false;
         ui_camera.orthographic = false;
     }
}

This works pretty well when i run this in Editor’s Game Window.

But when i build this project and run .exe
then there is no view matrix change

So i debugged this.
And i found that it seems Camera.main.orthographic property is changing well in built exe. False to True, True to False, but view doesn’t show that matrix (maybe).

Why this happen and how can i fix this?

I’m using Unity 2020.3.33f1 Personal and Project’s Render Pipeline is URP.

Thanks for your comments!!!

Easiest way would just have two cameras and swap between them instead.

Thanks for the reply !
Yes, but i just thought using 2 camera rendering SAME objects may cause lower framerate… eventhough turn off Camera components.

Pretty sure if a component is inactive, it’s inactive.

Only one way to find out, isn’t there? Shouldn’t take you long to test.

oh well, now i got this.
First, as you said i tested it, then the framerate average became a little bit lower.

And my problem, the main camera doesn’t change to orthographic actually,
the script of camera interface needs

public Camera

variable to be changed to orthographic.
When i do this with

Camera.main.orthographic = true;

the Editor’s Game simulate works well but not the built one.
But with specific variable of camera that i want to change projection mode, like

public Camera mainCamera;
mainCamera.orthographic = true;

This works well Editor and Built exe both.

Maybe Camera.main.~~ things is supposed to search Main Camera in current view, not that camera i want to search as main, So… i have to set SPECIFIC camera to the script.

Thanks for your attention anyway :smile: :smile: