The size of the SceneView window

Hi,

I am trying to find a workaround for the incorrect Screen.width and Screen.height values in edit mode (not running the game). I found out that this messes up the projectionMatrix of a camera in the scene. This projection matrix is strangely enough not related to the GameView size (which I have thanks to Bunny83 in the answer to this question: Game window size from editor window in editor mode - Questions & Answers - Unity Discussions) but it’s related to the width and height of the SceneView. I tried messing around with it and noticed that the projection matrix was changing only when I resized the SceneView. Now I am trying to calculate the same values of the projectionMatrix at runtime, but then in edit mode. I already have the SceneView object with the position property which give me these values but when I use them to calculate it seems that there is a little gap between the number I suppose to have and the number I actually have. That gap is a difference in height of 22 pixels (so the value I calculate is correct when subtracting it from the SceneView.position.height if the SceneView is a child of the main window, or adding the 22 pixels if the scene view is floating anywhere on the screen). So my question is if there is some way to either get the right projectionMatrix in edit mode (which seems related to ‘bug’ in the Screen.width and Screen.height values) or to get the SceneView’s width and height that are used to calculate the projectionMatrix of a camera in edit mode. I know it’s just a matter of adding or subtracting the 22 pixels but I don’t know if the SceneView is embedded in the main window or is floating around in some other Unity-user’s environment. Or is there a way to find that out?

It’s frustrating to be so close to a solution… :slight_smile:

thanks in advance for any help on this subject!

Ok, I’ll be the first to answer then, found the problem, I mixed up the values somewhere… don’t know exactly where (values of the scene view and game view). I know have the right projectionMatrix in edit mode which I set to the camera’s property and all calculations in edit mode are correct.

Sorry for my unseemingly complex and confusing question.