- Home /
When does camera aspect ratio data become available?
Hi! I have some logic that depend on the aspect ratio of a camera. It seems that this data is not available until the first Update, that is, not even in Start(). Even waiting for a second doesn't change the result. I expect that Start is run during compilation. Is it?
When I moved the setup logic into Update, I started getting the data I needed. I don't know how to get the correct aspect when running in the editor either, which makes things a lot harder. All I get is the aspect of the scene view.
Answer by Demigiant · Dec 01, 2011 at 02:09 AM
Compilation is when you, uhm, "compile" your project, and no methods are called. Then, when you start playing, the sequence is: Awake (once) > Start (once) > Update (repeated every frame), as Jake-GR said.
Getting the aspect ratio of a camera in the Editor is hell, especially if you're using Screen.width/height, because while it's not playing, Unity will return the width/height of the focused panel, instead than of the camera screen. A workaround I found is having the function that gets the size inside a MonoBehaviour attached to the camera: calling it from a Window/Inspector did the trick. Though, there was something else I had to do to make it work, but I can't remember exactly what - you will need to investigate a little :P
Answer by HolBol · Nov 30, 2011 at 08:36 PM
Start runs when the script is initialized, I believe when activated.
Nothing is run during compilation, its just compiled
Awake() gets run (once) when it first gets loaded, Start() gets run (once) before the first Update()
I did not get the chance to test exactly what happens to the camera aspect data between start and update, but It's definitely something I didn't expect. I wonder what happens and why.
Your answer
![](https://koobas.hobune.stream/wayback/20220613061336im_/https://answers.unity.com/themes/thub/images/avi.jpg)