【Unity3D游戏开发】WWW工具类简单的HTTP访问 (三四)
来源:互联网 发布:网络诈骗妇女案例 编辑:程序博客网 时间:2024/05/20 11:20
WWW是UNITY提供的访问HTTP的简单的工具类,可以从网络上下载配置、图片、录像等资源。
支持协议有 http:// https:// file:// ftp://
官方使用例子: 从网络上下载一张图片
// Get the latest webcam shot from outside "Friday's" in Times Squareusing UnityEngine;using System.Collections;public class ExampleClass : MonoBehaviour {public const string url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";void Start(){StartCoroutine(StartDownload(url, (tex) =>{// 下载图片后已经是一段时间后了,需要检测控件的有效性Renderer renderer = GetComponent<Renderer>();renderer.material.mainTexture = tex;}));}IEnumerator StartDownload(string url, Action<Texture2D> act) {// url可以是网络网址,也可以是本地网址WWW www = new WWW(url);// 检测是否下载完毕,也可以通过IsDone函数检测yield return www;if (!string.IsNullOrEmpty(www.error)) {if (act != null) {act(www.texture);}}// 释放资源www.Dispose();}}
官方文档:http://docs.unity3d.com/ScriptReference/WWW.html
参考文章:http://blog.csdn.net/mfc11/article/details/8188785
1 0
- 【Unity3D游戏开发】WWW工具类简单的HTTP访问 (三四)
- 读《Unity3D游戏开发》笔记工具类
- unity3d游戏开发简单画线
- Delphi开发工具中如何访问数据库结构 中国教程在线,http://www.5istudy.cn
- android+unity3D游戏开发之简单的碰撞检测
- android+Unity3D游戏开发之简单的物体运动
- android+unity3D游戏开发joint的简单运用
- Unity3D游戏开发之简单的碰撞检测
- unity3d游戏开发之简单的透明shader技能培训
- unity3D简单的汽车游戏
- Unity3D的WWW类使用
- HTTP访问工具类
- [Unity3D]Unity3D游戏开发之史上最简单的鼠标点击控制人物走动实现
- [Unity3D]Unity3D游戏开发之NPC对话系统的简单实现
- Unity3D游戏开发的利器?
- unity3d 4.3中新的开发工具2d游戏开发系统的初体验
- 强大的游戏开发工具Unity3D推出2D开发工具,unity将混合3D与2D开发
- [Unity3D]手机3D游戏开发:使用UnityRemote开发一个简单的FPS案例
- MySQL DateFormat函数
- CDOJ 1300 Easy Problem
- 【HDU5652 BestCoder Round 77 (div1) B】【并查集 or 二分答案BFS】India and China Origins 两国中间出现山脉 最早时间断绝联系
- Apache Kylin 大数据时代的OLAP利器
- Android ViewPager指示器 IndicatorBar
- 【Unity3D游戏开发】WWW工具类简单的HTTP访问 (三四)
- android代码上库流程
- 纯真IP数据库格式详解
- C语言二叉排序数算法
- CDOJ 1297 bank
- Dagger2生成代码解析
- 搭建react-native for android的windows开发环境
- mybatis学习笔记
- Android Studio的常用设置