WWW.WWW 构造WWW

static function WWW (url : string) : WWW

Parameters参数

Returns

WWW - A new WWW object. When it has been downloaded, the results can be fetched from the returned object.

返回WWW类型,一个新的WWW对象。当它被下载,其结果可以从返回的对象中获取。

Description描述

Creates a WWW request with the given URL.

用给定的URL创建一个WWW请求。

This function creates and sends a GET request. The stream will automatically start downloading the response.

这个函数创建和发送一个GET请求,流将自动开始下载响应。

After the stream is created you have to wait for it to complete, then you can access the downloaded data. As a convenience the stream can be yielded, so you can very easily tell Unity to wait for the download to complete.

流创建之后,你必须等待它完成,然而可以访问已下载的数据。作为一个方面的流可以被中断,因此你可以容易的告诉Unity等待下载完成。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public string url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
	IEnumerator Start() {
		WWW www = new WWW(url);
		yield return www;
		renderer.material.mainTexture = www.texture;
	}
}
// Get the latest webcam shot from outside "Friday's" in Times Square
// 获取时代广场最新的外部"Friday" web摄像头数据 
var url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
function Start () {
	// Start a download of the given URL
	// 开始下载给定的URL
	var www : WWW = new WWW (url);

	// Wait for download to complete
	// 等待直到下载完成
	yield www;

	// assign texture
	//指定纹理
	renderer.material.mainTexture = www.texture;
}

• static function WWW (url : string, form : WWWForm) : WWW

Parameters参数

Returns

WWW - A new WWW object. When it has been downloaded, the results can be fetched from the returned object.

返回WWW类型,一个新的WWW对象。当它被下载,其结果可以从返回的对象中获取。

Description描述

Creates a WWW request with the given URL.

用给定的URL创建一个WWW请求。

This function creates and sends a POST request with form data contained in a WWWForm parameter. This is the same as calling new WWW(url,form.data, form.headers). The stream will automatically start downloading the response.

这个函数创建和发送一个POST关于表单数据包含一个WWWForm参数的请求。这是与调用new WWW(url,form.data, form.headers)相同的。流将自动开始下载响应。

After the stream is created you have to wait for it to complete, then you can access the downloaded data. As a convenience the stream can be yielded, so you can very easily tell Unity to wait for the download to complete.

流创建之后,你必须等待它完成,然而可以访问已下载的数据。作为一个方面的流可以被中断,因此你可以容易的告诉Unity等待下载完成。

• static function WWW (url : string, postData : byte[]) : WWW

Parameters参数

Returns

WWW - A new WWW object. When it has been downloaded, the results can be fetched from the returned object.

返回WWW类型,一个新的WWW对象。当它被下载,其结果可以从返回的对象中获取。

Description描述

Creates a WWW request with the given URL.

用给定的URL创建一个WWW请求。

This function creates and sends a POST request with raw post data contained in postData. The stream will automatically start downloading the response. Use this version if you need to post raw post data in a custom format to the server.

这个函数创建和发送一个POST关于元素post数据包含在postData的请求。流将自动开始下载响应。如果你需要post在一个自定义格式的原始postData到服务器,使用这个版本。

After the stream is created you have to wait for it to complete, then you can access the downloaded data. As a convenience the stream can be yielded, so you can very easily tell Unity to wait for the download to complete.

流创建之后,你必须等待它完成,然而可以访问已下载的数据。作为一个方面的流可以被中断,因此你可以容易的告诉Unity等待下载完成。

• static function WWW (url : string, postData : byte[], headers : Hashtable) : WWW

Parameters参数

Returns

WWW - A new WWW object. When it has been downloaded, the results can be fetched from the returned object.

返回WWW类型,一个新的WWW对象。当它被下载,其结果可以从返回的对象中获取。

Description描述

Creates a WWW request with the given URL.

用给定的URL创建一个WWW请求。

This function creates and sends a POST request with raw post data contained in postData and custom request headers supplied in the headers hashtable. The stream will automatically start downloading the response. Use this version if you need to post raw post data in a custom format to the server or if you need to supply custom request headers.

这个函数创建和发送一个POST关于元素post数据包含在postData并且在哈希表头自定义请求headers的请求。流将自动开始下载响应。如果你需要post在一个自定义格式的原始postData到服务器或如果您需要提供自定义请求表头,使用这个版本。

After the stream is created you have to wait for it to complete, then you can access the downloaded data. As a convenience the stream can be yielded, so you can very easily tell Unity to wait for the download to complete.

流创建之后,你必须等待它完成,然而可以访问已下载的数据。作为一个方面的流可以被中断,因此你可以容易的告诉Unity等待下载完成。

最后修改:2011年4月25日 Monday 9:24

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。