Unity: Having trouble in taking screenshot for the content inside scrollView

I am new in Unity. I’m trying to make a code that will take a screenshot of a object inside scrollview. My problem is that the whole object/image inside the scrollView is not visible in device.I have to pan the scrollView to see the hidden/remaining part of the object.What I wanna do is to take the screenshot of the whole object/image inside the scrollview. Please help

My code below is

 private IEnumerator TakeScreenshot()
    {
    yield return new WaitForEndOfFrame();

    var width = Screen.width;
    var height = Screen.height;
    var tex = new Texture2D(width, height, TextureFormat.RGB24, false);
    // Read screen contents into the texture
    tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
    tex.Apply();
    byte[] screenshot = tex.EncodeToPNG();
}

Code above only takes the screenshot that is visible to the device screen. I want to take the screenshot the whole object/image. Please help

So…you have an image that is in a scrollview…Why not just grab the image from there instead of trying to create a “screenshot”? A screenshot is what it is. It’s a shot of what is on the screen at the moment.

If the image is bigger than the screen, I don’t see a way you could take the picture of the object and create a true screenshot. It may be possible to take a shot of the screen and then the image and some how combine them. Otherwise, if you want the image all by itself, you should be able to use it’s texture and save that to png.

Depending on how you have things setup. You already have the basics in place for how to create the png, you just need to read in the correct texture to save it out.