Unity screenshots

Screenshot // 
    public void CaptureScreen2 (Camera C, R & lt Rect) 
    { 
        // Capturing camera image is converted into character array and   
        the RenderTexture the RenderTexture new new RT = ((int) r.width, (int) r.height, 0); 

        // targetTexture target texture 
        c.targetTexture = RT; 
        // render rendering manual camera 
        c.Render (); 

        // currently active in the active render texture 
        RenderTexture.active = RT; 
        Texture2D SCREENSHOT new new Texture2D = ((int) r.width, (int ) r.height, TextureFormat.RGB24, to false); 
        // read pixel 
        screenShot.ReadPixels (R & lt, 0, 0); 
        screenShot.Apply (); 

        // render target texture camera 
        c.targetTexture = null;  
        RenderTexture.active = null;
        GameObject.Destroy ( rt);

        // this texture coding PNG format. 
        byte [] bytes = screenShot.EncodeToPNG (); 

        String @ filename = "D: \ Photo-whzq \ Screenshot.png"; 
        System.IO.File.WriteAllBytes (filename, bytes); 
        PlayerPrefs.SetString (ImageFile, filename); 


    }

  

Guess you like

Origin www.cnblogs.com/clhxxlcj/p/10972644.html