Download and save the Unity3d pictures

Source: Internet
Author: User

Unity3d Download and save the pictures: Unity3d 2013-06-24 15:03 3609 people read reviews (2) Favorite report Unity3d picture URL code is as follows: [CSharp] View plaincopy using Unityengine  ;  Using System.Collections;    Using System.IO;      public class Downpicture:monobehaviour {public gameobject plane;      www www;      String FilePath;      Texture2d test;      Texture2d newtexture; Use the this for initialization void Start () {FilePath = Application.datapath + "/resources/pictu                    Re.jpg ";              if (System.IO.File.Exists (FilePath)) {Debug.Log ("File already exists");              Test = (texture2d) resources.load ("Picture", typeof (Texture2d));          plane.renderer.material.mainTexture = test;              } else {Debug.Log ("file start download");                        Startcoroutine (GetImage ()); }}//update is called once per frame void update () {} ienum Erator GetImage () {string URL = "Http://192.168.2.105:8080/Test/picture/1.jpg";          www = new www (URL);          yield return www;                    Newtexture = www.texture;          byte[] Pngdata = Newtexture.encodetopng ();               File.writeallbytes (FilePath, pngdata); } void Ongui () {if (Www.isDone) {Plane.renderer.material.mai                Ntexture = newtexture;   }      }  }

Download and save the Unity3d pictures

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.