Question by
DamDamDuSixZero · May 26, 2017 at 02:05 AM ·
cameraresolutionchangewidth
Changing resolution affect camera width but not height
Hi everybody !
I need to know the width and height of my camera because i want to place some GameObject at a point from the camera border. I made many research and many people says that i could obtain these information with this code :
Camera cam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
float vertExtent = cam.orthographicSize;
float horzExtent = vertExtent * Screen.width / Screen.height;
float cameraWidth = horzExtent * 2;
float cameraHeight = vertExtent * 2;
print("taille de la camera H : " + cameraWidth + " V = " + cameraHeight);
But this code doesn't give me the same results for the width when i change the game's resolution ( but the height stay the same ! )
Can someone explain me why and maybe give me a solution for getting the same camera width when I change resolution ?
Thanks in advance
Comment
Your answer
Follow this Question
Related Questions
Need Help in understanding ScreenToWorldPoint 0 Answers
How to Remove the black bar at my game window? 0 Answers
Adapted camera to resolution but not canvas. 0 Answers
Letterboxing issues 0 Answers