WWWForm.data 数据

var data : byte[]


(Read Only) The raw data to pass as the POST request body when sending the form.


Usually, you just pass the WWWForm object directly to the WWW constructor, but you will need this variable if you want to change the request headers sent to the web server.


参见: headers 变量.

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public WWWForm form = new WWWForm();
	public System.Collections.Hashtable headers = form.headers;
	public byte[] rawData = form.data;
	public string url = "www.myurl.com";
	public WWW www = new WWW(url, rawData, headers);
	public IEnumerator Awake() {
		form.AddField("name", "value");
		headers["Authorization"] = "Basic " + System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("username:password"));
		yield return www;
var form = new WWWForm();
form.AddField( "name", "value" );
var headers = form.headers;
var rawData = form.data;
var url = "www.myurl.com";

// Add a custom header to the request.
// In this case a basic authentication to access a password protected resource.
// 给请求添加一个自定义的头,在这里用一个简单的授权来访问密码保护的资源
headers["Authorization"]="Basic " + System.Convert.ToBase64String(

// Post a request to an URL with our custom headers
// 用自定义的头传递一个请求到URL
var www = new WWW(url, rawData, headers);
yield www;
//.. process results from WWW request here...
// 这里处理WWW请求结果…
Page last updated: 2011-3-19