- Home /
Setting camera.ortographic = true should work?
I am probably missing something obvious. I tried to set a camera to orthographic mode:
public void Awake() { Camera.main.orthographic = true; Camera.main.orthographicSize = 5;
// or...
// GameObject cameraObj = GameObject.FindWithTag("MainCamera");
// Camera camera = (Camera) cameraObj.GetComponent(typeof(Camera));
// camera.orthographic = true;
// camera.orthographicSize = 5;
}
...but the camera projection doesn't change (it is still "perspective"). What is wrong?
EDIT: Sorry for asking too fast. It works. For some reason the camera values aren't updated in the inspector if the camera is selected when you play. If a different object is selected before start playing, the camera projection is set to "ortographic" in the inspector when you select it. A small bug I guess...
is the camera tagged as "$$anonymous$$ain Camera"? You could also set it to true In the editor.
It is correctly tagged (the default tag wasn't changed). It is a $$anonymous$$or bug in the editor apparently, which isn't updated if the selected object is the camera when you start playing (see my edit).
Your answer
![](https://koobas.hobune.stream/wayback/20220613082719im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
put prefab in top left of the camera 0 Answers
ScreenToWorldPoint for different ortographic size 1 Answer
Camera orthographic size not changing 0 Answers
SmoothDamp bounce effect 0 Answers
Synced position with two cameras? 0 Answers