Search Unity

Capturing Screenshot of a Rect Transform

Discussion in 'UGUI & TextMesh Pro' started by gfxguru, May 4, 2016.

  1. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
    hi,
    I have an app that need to take screenshot from a specific area of the screen, that covering a Rect Transform. I am using the following code to get screenshot of an area. But i am confused how i can get the pixel rect from the Rect transform that are needed by the below code. Please help.


    Code (CSharp):
    1. Texture2D tex = new Texture2D (width, height, TextureFormat.RGB24, false);
    2.  
    3. tex.ReadPixels (new Rect (0,0, width, height), 0, 0);
    4.  
    5. tex.Apply ();
    Thanks in advance
     

    Attached Files:

    Last edited: May 4, 2016