Unity+ngui Implementation screenshot Plus biography

Source: Internet
Author: User

IEnumerator CaptureScreenshot2 (Rect Rect) {//Create an empty texture first, the size can be set according to the implementation needs texture2d screenshot = new Tex
        Ture2d (Screen.width, screen.height/*, Textureformat.rgb24, false*/); Canvas.
        SetActive (false);//Screen UI yield return new Waitforendofframe ();
        Reads screen pixel information and stores it as texture data, screenshot.readpixels (rect, 0, 0);

        Screenshot.apply ();
        Then put these texture data into a PNG picture file byte[] bytes = Screenshot.encodetopng (); Canvas. 
        SetActive (TRUE);
        -----Create a picture locally string filename = Application.datapath + "/screenshot.png";
        System.IO.File.WriteAllBytes (filename, bytes); Debug.Log (String.
        Format ("Screenshot of a picture: {0}", filename));
        Create a picture-----network string tempS = System.Convert.ToBase64String (bytes);
        Wwwform form = new Wwwform (); Form.
        AddField ("image", TempS);
        www www = new www ("http://project.weily.org/uim/index.php", form);
        yield return www;
        Print (Www.text); //-----In ngui3xx version, copy the path to the clipboard texteditor te = new TextEditor ();
        Te.content = new Guicontent ("http://project.weily.org/uim/" + www.text); Te.
        Onfocus (); Te.
    Copy ();   }


Note Notes ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.