How to find out the real viewport/screen size in Scene view?

Screen.width/height always returns 640x480 in Scene view. Is there a workaround for this?

Found a way using Unity's hidden "SceneCamera". This camera can only be found when the scene-view is visible and focused:

GameObject sceneCamObj = GameObject.Find( "SceneCamera" );
if ( sceneCamObj != null )
{
    // Should output the real dimensions of scene viewport
    Debug.Log( sceneCamObj.camera.pixelRect );
}

Camera.current.pixelRect is the true one.

or GetWindow<SceneView>().camera.pixelRect

These two vectors here get the screensize:

Vector2 screenBounds = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height));
Vector2 screenOrigo = Camera.main.ScreenToWorldPoint(Vector2.zero);

Then if i want to check if something is going outside the screenRect i can check it with:

Vector3 pos = transform.position;
if (pos.x > screenBounds.x || pos.x < screenOrigo.x)
{
    DoStuff();
}
else if (pos.y > screenBounds.y || pos.y < screenOrigo.y)
{
   DoStuff();
}

Here is the solution, which takes into the account the Scene-View’s ribbon:

https://forum.unity.com/threads/mouse-position-in-scene-view.250399/#post-3760579