Http下载Demo
来源:互联网 发布:js动态删除指定tr 编辑:程序博客网 时间:2024/06/05 10:53
public class ImageTest : MonoBehaviour {string url = "http://www.yxk.com:8000/test.png";private Texture2D img = null;private Texture2D img2 = null;private bool downloadOK = false;enum GetPicType {DownLoad = 0,LoaclLoad}void OnGUI(){if( this.img != null ){GUI.DrawTexture(new Rect(0,0,200,300),this.img );}if( this.img2 != null ){GUI.DrawTexture(new Rect(320,0,200,300),this.img2 );}if( GUI.Button (new Rect (210, 50, 100, 30), "网络加载") ) {StartCoroutine( this.DownLoadTexture( this.url, GetPicType.DownLoad ));}if( GUI.Button (new Rect (210, 150, 100, 30), "本地加载") ) {if( this.downloadOK ){StartCoroutine( this.DownLoadTexture( "file://" + Application.streamingAssetsPath + "/test.png", GetPicType.LoaclLoad ));}else{}}}IEnumerator DownLoadTexture( string url, GetPicType getType ){WWW www = new WWW (url);yield return www;Texture2D tempImage = null;if( www.isDone && www.error == null ) {switch( getType ){case GetPicType.DownLoad:{this.img = www.texture;tempImage = this.img;break;}case GetPicType.LoaclLoad:{this.img2 = www.texture;tempImage = this.img2;break;}default:{break;}}}if( tempImage != null ) {byte[] data = tempImage.EncodeToPNG();System.IO.File.WriteAllBytes( Application.streamingAssetsPath + "/test.png", data );this.downloadOK = true;}}}
0 0
- Http下载Demo
- RTMP服务器和HTTP服务器DEMO下载
- Qt的http下载的Demo
- 一个下载Http文件到本地的Demo
- 用I/O完成端口+socket编写客户端demo实现Http下载
- http://demo.dwzjs.com/#
- Http Post Get Demo
- REST,HTTP POST demo
- https http请求 demo
- http://fineui.com/demo/
- nodejs http simple demo
- HTTP下载
- http下载
- http下载
- http 下载
- HTTP下载
- http下载
- 指纹识别Demo 源代码下载
- 2016.4.7Python递归函数
- C#-委托与事件
- POJ3259----Wormholes(SPFA判断负环)
- JAVA 冒泡排序-个人理解
- swift中得ios设计模式
- Http下载Demo
- Makefile 学习整理
- 人生的感悟
- PHP学习(十三)--预定义数组
- web项目中javax.servlet.ServletExcecption: java.lang.ClassNotFoundException: com.mysql.jdb.Driver
- ORACLE中用rownum分页并排序的SQL语句
- KVC
- C++对象模型浅析
- iOS使用NSMutableAttributedString 实现富文本(不同颜色字体、下划线等)