Error getting overlay screenshot

Hello, I’m trying to get a screenshot of an overlay canvas, so I need to use the ReadPixels method. The problem is that I’m getting the left grey space of the game view that is suposedly out of the screen on my screenshot.
I have found that I need to change the x param (1st param) of readpixels, but as I don’t understand what’s hapenning I don’t know the correct value to pass.

tex = new Texture2D(Screen.width, Screen.height);
tex.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
tex.Apply();

Thank you!

It’s solved now, I needed to WaitForEndFrame() for the image to be completely rendered.